The previous solution is to add the file, then create an engagement of type Note and add the association with ticketIds. However, new API version has deprecated ticketIds:
“ticketIds”: [] // Deprecated, has no effect on the engagement
Using the Node api-client. How is this now handled?
Hey, @Michael_Byers
Can you share an example request, response, and full error body, please? This is helpful for our community members, and me, to troubleshoot alongside you.
Thanks! — Jaycee
I found the solution, not trying to create an engagement but just creating a note. This slightly changed for v3.
async function addNoteToHubSpot(fileId, ticketId, timestamp) {
try {
// Create a NOTE engagement for the case. We'll include the attachment ID.
const noteData = {
properties: {
hs\_timestamp: timestamp,
hs\_note\_body: 'Attaching file to ticket from SF',
hs\_attachment\_ids: Number(fileId)
},
//association typeIds https://legacydocs.hubspot.com/docs/methods/crm-associations/crm-associations-overview
associations: \[{
to: {id: Number(ticketId)},
types: \[{ associationCategory: 'HUBSPOT\_DEFINED', associationTypeId: 18 }]
}]
};
const response = await hubspotClient.crm.objects.notes.basicApi.create(noteData);
return true;
} catch (error) {
logMessage('\*\*\*\*ERROR adding note to HubSpot for ticket: ' + ticketId + ' : ' + error);
}
return null;
}