APIs & Integrations

OHafez
Member

Attach a file to a ticket

I've been really struggling to attach a file to a ticket using the HubSpot API. I was able to upload a file and a ticket separately, and I'm able to see those in the hubspot web portal as well. I'm also able to attach manually through the web portal, but I've had no luck using the engagements API or creating associations within the ticket API payload.

 

Can someone show me how this can be done using the most recent API?

Here's what the payload looked like in my most recent attempt using the https://api.hubapi.com/crm/v3/objects/notes endpoint:

{
"properties": {
"hs_note_body": "Spoke with decision maker john",
"hs_timestamp": "2019-10-30T03:30:17.883Z"
},
"associations": [
{
"to": {
"id": "148491852472"
}
},
{
"to": {
"id": "2144387924"
}
}
]
}

 I end up getting a response that an engagement has been created. but I don't see the note anywhere and I don't see the file being attached to the ticket either. Not sure what's going on here. 

I've tried a variety of things and I'm wondering if anyone was able to get it working on their end and can explain how they set it up.

0 Upvotes
2 Replies 2
Jaycee_Lewis
Community Manager
Community Manager

Attach a file to a ticket

Hey, @OHafez 👋 Have you already tried following the steps here — Attaching files to object via the APIs? Although I show this using a Deal, the process is the same.

The tldr is – it will take multiple calls – 

  • Upload the file
  • Create a Note
  • Associate the File to the Note
  • Associate the Note to the Object

Have fun building! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
edornor
Member

Attach a file to a ticket

Hi @Jaycee_Lewis 
Attempting to create a note using the method mentioned in the linked post does not seem to work. (with linking a file [private or public_not_indexable] to a note)
API endpoint - https://api.hubapi.com/crm/v3/objects/notes​

I get "Unable to infer object type from: notes​" - whether or not I include ids in 

hs_attachment_ids, whether "hs_attachment_ids" field is left out completeley, or whether the "associations" field is provided in the request.

Trying the online request:
https://developers.hubspot.com/docs/api/crm/notes#endpoint?spec=POST-/crm/v3/objects/notes
It forces an associate ID to be provided. And in providing the file id and using association type id - 190, the following error is received:

HTTP 400

{
"status": "error",
"message": "one or more associations are not valid",
"correlationId": "XXXX",
"errors": [
{
"message": "0-2=XXXID is not a valid object",
"context": {
"validationResult": [
"INVALID_FROM_OBJECT"
]
}
}
],
"category": "BAD_REQUEST"
}



0 Upvotes