Hi
I am trying to associate between a ticket to a contact using the hubspot api - node.js but having trouble would apreciate for an example on how to do it.
Thanks!
Hi
I am trying to associate between a ticket to a contact using the hubspot api - node.js but having trouble would apreciate for an example on how to do it.
Thanks!
Hi @TYona
- Can you post your code (inside a code bloc, the </> icon in the formatting toolbar) so that i can help you.
- What’s is your issue ? An error messsage as api response ? If yes which one
Thanks @quentin_lamamy !
Below you may find the code and the error
the error is:
UnhandledPromiseRejectionWarning: Error: Required parameter ticketId was null or undefined when calling create.
at AssociationsApi.
const hubspot = require('@hubspot/api-client')
const hubspotClient = new hubspot.Client({apiKey: 'MYAPIKEY'})
const contactObj = {
properties: {
firstname: 'T',
lastname: 'Test',
email: 'ty@example.com',
company: 'Texample'
},
}
const ticketObj = {
properties: {
"hs_pipeline": "0",
"hs_pipeline_stage": "1",
"hs_ticket_priority": "HIGH",
"hubspot_owner_id": "5555555",
"subject": "test association"
}
};
// create ticket
const createTicketResponse = hubspotClient.crm.tickets.basicApi.create(ticketObj)
// create contact
const createContactResponse = hubspotClient.crm.contacts.basicApi.create(contactObj)
function addTicket(){
return hubspotClient.crm.tickets.associationsApi.create(createTicketResponse.body, "tickets", createContactResponse.body, "", undefined, undefined)
}
addTicket()
.then(console.log('done'))
.catch(console.log('error'))
This is an old thread and I’m sure it was solved, yet if someone arrives here with the same issue, you should have supplied the ticketId and the contactId, respectively, wherever you’ve send the body of the response.
Hi, I don’t have the documentation of the node sdk , you should check first the parameter of the method. If the expected first parameter of the method is the ticket id you should check if createTicketResponse.body contain the id, please check doc, dump the value and post here the value of this variable
Hi,
Thanks again!
After checking it seems that the id is undefined.
I used this documentation, still no luck with assocation of a contact to a ticket.
I’d appreciate an example of it using the sdk from someone in the community ![]()
Thanks!
Hi,
Can you give me the link of the documentation you are following and post the dump of createTicketResponse
Actually I managed! The problem was with js rather then the api itself.
Thanks Quentin!
If your issue is solved don’t forget to flag your post as solved.