1

This is through the REST API, I'm using CiviCRM 4.4.14, REST API v3.

I read that there is an attachment API, but the attachment API does not seem to be available through the REST API.

1

I think you're right. The table that links attachments to what they're attached to is civicrm_entity_file, and the table with details of the file itself is civicrm_file. In 4.4 (and indeed 4.6 and 4.7) the former has its own DAO but isn't its own API entity.

If you want to get details of the attachments on some entity, you might need to write a custom API function wrapping CRM_Core_BAO_File::getEntityFile.

One way you can present a link to the user to download the attachment, is /civicrm/file?id=<file ID>&eid=<activity ID>, but they'll need the 'access uploaded files' permission. On Drupal (I don't know about roles and permissions in Wordpress) this means they'd either need to be actually logged into Civi with a role that has that permission, or the permission would need to be granted to anonymous users, which would mean anybody could grab any attachment by guessing the numbers.

Another way you could allow your app to download an attachment is to write a custom API that base64-encodes the file contents and includes that in the API result.

  • Hmm, I hadn't actually heard about the Attachment.get API before as I'm on 4.4 myself. It's not in 4.4 but is in 4.6 and 4.7. – DaveFF Apr 14 '16 at 9:19
  • See this question: civicrm.stackexchange.com/q/9586/2 – DaveFF Apr 14 '16 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.