how can I fetch files/attachments associated with a contact on a private page? The flow:
1. User (from the list) login in a private page
2. After login we grab the contact ID
3. Based on ID we get attachments associated with contact.
but, can I:
1. query the API using jQuery/JS directly from the website? (CORS policy issue)
2. use the API (combination of different endpoints) to get the URL of these files and then display them on the target site?
3. if so, can someone send some usage examples of what should be used to get them?
Hi @Dawidk
You can follow the following steps:
1. To get contact’s association through contact id
curl --request GET \
--url ‘https://api.hubapi.com/crm/v3/objects/contacts{contactId}? associations=notes&archived=false’ \
--header ‘authorization: Bearer YOUR_ACCESS_TOKEN’
hit this api first to get asssociation (notes) as a query param you’ll get its id then you have to hit this api
===
2. After get association id of notes then hit a call for get notes attachments ids
curl --request GET \
--url ‘https://api.hubapi.com/crm/v3/objects/notes{noteId}? properties=hs_attachment_ids&archived=false’ \
--header ‘authorization: Bearer YOUR_ACCESS_TOKEN’
===
3. Hit at last
call files api by id
curl --location ‘https://api.hubapi.com/filemanager/api/v2/files{attachmentId}’ \
--header ‘authorization: Bearer YOUR_ACCESS_TOKEN’
Hope this will helps you out. Please mark it as Solution Accepted & Upvote to help other Community member.
Thanks!