Get an attachment using APIs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LamurCorp
    Junior Member
    • Apr 2020
    • 2

    Get an attachment using APIs

    Such a good product!
    I've looked at the documentation of the APIs, the sad fact is, most of it is terrible described. I'm sorry for being rude.
    Please advice how to get an Attachment (file) using APIs.


    API request:
    Attachment/5e95750bccc13d6d2

    API results:

    PHP Code:
    [response] => {"id":"5e95750bccc13d6d2","name":"image.png","deleted":false,"type":"image\/png","size":48493,"sourceId":null,"field":"image","createdAt":"2020-04-14 08:32:11","role":"Attachment","storage":null,"storageFilePath":null,"global":false,"parentId":null,"parentType":null,"parentName":null,"relatedId":"5e956201647c76d31","relatedType":"Account","relatedName":"7","createdById":"1","createdByName":"Admin"}
    [code] => 200 
    
  • yuri
    Member
    • Mar 2014
    • 8442

    #2
    It's not possible via API.

    When you download an attachment in EspoCRM it redirects to '?entryPoint=download&id=ATTACHMENT_ID'

    It's possible to download this way but it will require a basic authorization.

    EDIT:

    It will be added in the next release: https://github.com/espocrm/espocrm/issues/1676. You can apply code from the commit to your instance manually.
    Last edited by yuri; 04-14-2020, 04:38 PM.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment


    • esforim
      esforim commented
      Editing a comment
      Note on those eager for this feature. It is schedule for EspoCRM-5.9.0
  • LamurCorp
    Junior Member
    • Apr 2020
    • 2

    #3
    Big thanks, it works fine for auth with regular user.

    FYI: HMAC auth doesn't work

    Get Metadata - OK
    PHP Code:
    $response = $api->request('GET', 'Attachment/5e95750bccc13d6d2'); 
    
    Get File - Nothing
    PHP Code:
    $response = $api->request('GET', 'Attachment/file/5e95750bccc13d6d2'); 
    

    Comment

    Working...