CMS Development

yorambaron
Participante

How to create an attachment for a ticket by using the API

Hello,

 

I am converting a ticket entity from another system to HubSpot.

How can I create an attachment to a ticket by using the API?

Can I update the 'hs_file_upload' property by using this link  or this is a read only property?

If this is not possible, should I associate the attachment to a contact and then associate the ticket to this contact?

 

Is there any other way?

 

Regards,

Yoram

0 Avaliação positiva
2 Respostas 2
lscanlan
Alunos da HubSpot
Alunos da HubSpot

How to create an attachment for a ticket by using the API

Hi @yorambaron,

 

This is possible using the Engagements API, which you can find our docs for here: https://developers.hubspot.com/docs/methods/engagements/engagements-overview. So in your case, you should first create the ticket using the endpoint listed here: https://developers.hubspot.com/docs/methods/tickets/create-ticket. When you create a ticket you'll receive its ID in the response. Store that ticket ID.

 

You'll also want to upload your file to the File Manager via the CMS Files API. You can do that with the endpoint and instructions documented here: https://developers.hubspot.com/docs/methods/files/post_files. You'll also receive the file's ID in the response from that API. Store the file's ID.

 

Then you'll attach the file to the ticket by creating a NOTE type engagement (endpoint documented here: https://developers.hubspot.com/docs/methods/engagements/create_engagement) and using those stored IDs. The engagement will be associated to the ticket and will have the file attached to the engagement. Here's an example post body for this request:

 

{
  "associations": {
    "ticketIds": [
      56851696
    ]
  },
  "engagement": {
    "type": "NOTE"
  },
  "metadata": {
    "body": ""
  },
  "attachments": [
    {
      "id": 20532394005
    }
  ]
}

 

I hope this helps and let me know if you have any questions.

 

Leland Scanlan

HubSpot Developer Support
0 Avaliação positiva
yorambaron
Participante

How to create an attachment for a ticket by using the API

Thank you, this really helps!

0 Avaliação positiva