Create ticket with note and attachment with v3

Hi all,

I’m trying to use the HS v3 api to create a ticket, create a note with an attachment and then link the note to the ticket I have created.

I have done this with the following steps:
Step 1 POST request to create ticket

curl --request POST \
--url https://api.hubapi.com/crm/v3/objects/tickets \
--header ‘Authorization: Bearer *tokengoeshere*’ \
--header ‘Content-Type: application/json’ \
--data ‘{
“properties”: {
“subject”: “Test Ticket”,
“content”: “This is an example test ticket.”,
“hs_pipeline”: “11687163”,
“hs_pipeline_stage”: “2534224”
}
}’

Step 2 POST request to upload a file

curl --request POST \
--url https://api.hubapi.com/files/v3/files \
--header ‘Authorization: Bearer *token goes here*’ \
--header ‘Content-Type: multipart/form-data’ \
--form ‘file=@/Users/myuser/Downloads/myfile.pdf’ \
--form folderId=122522370400 \
--form ‘options={“access”:“PRIVATE”,“overwrite”: true,“duplicateValidationStrategy”: “NONE”,“duplicateValidationScope”: “EXACT_FOLDER”}’

Step 3 POST request to create note with file id in the hs_attachment_ids field

curl --request POST \
--url https://api.hubapi.com/crm/v3/objects/notes \
--header ‘authorization: Bearer *insert token here*’ \
--header ‘content-type: application/json’ \
--data ‘{
“properties”: {
“hs_timestamp”: “2019-10-30T03:30:17.883Z”,
“hs_note_body”: “This is a test”,
“hubspot_owner_id”: “190642446”,
“hs_attachment_ids”: “122623379372”
}
}’

These requests are all successful and return a 201 as expected.

I assume the next step is to make a call to associate the ticket with the note maybe?

I tried that with this request and got a 204:

curl --request POST \
--url https://api.hubapi.com/crm/v3/associations/ticket/note/batch/archive \
--header ‘authorization: Bearer *insert token here*’ \
--header ‘content-type: application/json’ \
--data ‘{
“inputs”: [
{
“from”: {
“id”: “1721906517”
},
“to”: {
“id”: “36674477149”
},
“type”: “ticket_to_note”
}
]
}’

Is this the correct approach? After I did this I viewed my ticket in the hubspot webclient and there is no new note created for the ticket? What is the correct approach here?

For anyone with the same issue I have now resolved my issue and was able to successfully do this using the following request:

curl --request POST \
--url https://api.hubapi.com/crm/v3/objects/notes \
--header ‘authorization: Bearer *token goes here*’ \
--header ‘content-type: application/json’ \
--data ‘{
“properties”: {
“hs_timestamp”: “2019-10-30T03:30:17.883Z”,
“hs_note_body”: “This is a test”,
“hubspot_owner_id”: “190642446”,
“hs_attachment_ids”: “122623379372”
},
“associations”: [
{
“to”: {
“id”: 1721906517
},
“types”: [
{
“associationCategory”: “HUBSPOT_DEFINED”,
“associationTypeId”: 228
} ]
}]
}’