Announcement

Collapse
No announcement yet.

Get an attachment using APIs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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 

  • #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.

    Comment


    • esforim
      esforim commented
      Editing a comment
      Note on those eager for this feature. It is schedule for EspoCRM-5.9.0

  • #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...
    X