Hi!
I am looking for a way to list out and download all the attachments associated with Ticketid using Python API.
Can someone please guide me through how to do this?
Hi!
I am looking for a way to list out and download all the attachments associated with Ticketid using Python API.
Can someone please guide me through how to do this?
Hey @NLE2 thank you for posting in our Community!
First, make sure you have your HubSpot API key ready. This key will be used to authenticate your requests.
Once you’ve retrieved the attachment data, extract the attachment URLs. To our top experts, @Anton, @DanielSanchez, and @Lucila-Andimol do you have any recommendations for @NLE2?
Thank you,
Pam
Hi Pam, thank you for your response. I have set up HubSpot API already, but I read all the HubSpot API but don’t see any API that supports getting files & downloading attachments in tickets, please help me solve this problem. Thank you
Hi @NLE2
Retrieving Attachments in HubSpot: An Iterative Approach
In HubSpot, attachments aren’t directly associated with specific CRM objects (contacts, deals, companies, etc.). Instead, they’re linked through engagements, which represent interactions with those objects. To retrieve an attachment, you’ll need to iterate through the relevant engagement types where it might be stored.
Understanding Engagement Types and Attachment Storage:
Steps to Retrieve an Attachment:
GET Associated Engagements
endpoint for notes:
``https://api.hubspot.com/crm/v3/objects/contacts/${objectId}/associations/engagements?typeId=1`; // 1 = Notes engagement type`
Replace
objectId
with the actual ID of your CRM object and update the
typeId
if targeting emails or other engagement types.
hs_attachment_ids
within the engagement object. This property, if present, will be an array containing the IDs of any attachments associated with that engagement.
GET File by ID
endpoint to retrieve additional information about the attachment, such as its filename and size:
``https://api.hubspot.com/files/v3/files/${attachmentId}`;`
Replace
attachmentId
with the ID you obtained from the engagement.
Hi @HubSpot_Corey, I tried your way, with objectID = 228 but it returned empty results even though I uploaded many attachments to the ticket like shown below. Because I need to sync the attachment from the HubSpot ticket to ADO using Python, so please help me resolve this problem.
Hi @NLE2,
Apologies, you need to change the “contacts” in the url to be the object you’re searching against. If this is tickets you will need to change it to tickets. For example:
``https://api.hubspot.com/crm/v3/objects/tickets/${objectId}/associations/engagements?typeId=1`; // 1 = Notes engagement type`
After this you will have a list of note objectIds, you can then loop each result using the following to extract any attachmentIds
``https://api.hubspot.com/crm/v3/objects/notes/${noteId}?properties=hs_attachment_ids`