We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Oct 3, 2022 8:43 AM
Hi all.
Can some kind person point out what I'm doing wrong with the code below on my custom workflow? Everything else in my code works, but once I try an update, I'm hit with all sorts of erros no matter how much I tweak.
hubspotClient.crm.objects.associationsApi.create({
"fromObjectId": contact_id,
"toObjectId": found_company_id,
"category": "HUBSPOT_DEFINED",
"definitionId": 1,
"associationType": "contact_to_company"
}
)
Many thanks in advance
Solved! Go to Solution.
Oct 4, 2022 7:42 AM
Hi Lee.
Thanks loads for the help. Between your feedback and a colleague I got there. It’s:
hubspotClient.crm.objects.associationsApi.create("CONTACT",contact_id,"COMPANY",found_company_id,"contact_to_company",1)
}
The main reason I was having issues was due to the fact that the you must explicitly state what the object type is before providing its ID number. I’d been trying this and it was still failing until I realised it’s case sensitive and must be in capitals, so ‘CONTACT’ and ‘COMPANY’ work.
Thanks for pointing me in the right direction Lee
Oct 4, 2022 7:42 AM
Hi Lee.
Thanks loads for the help. Between your feedback and a colleague I got there. It’s:
hubspotClient.crm.objects.associationsApi.create("CONTACT",contact_id,"COMPANY",found_company_id,"contact_to_company",1)
}
The main reason I was having issues was due to the fact that the you must explicitly state what the object type is before providing its ID number. I’d been trying this and it was still failing until I realised it’s case sensitive and must be in capitals, so ‘CONTACT’ and ‘COMPANY’ work.
Thanks for pointing me in the right direction Lee
Oct 3, 2022 9:15 AM - edited Oct 3, 2022 9:16 AM
Pretty sure you want this:
hubspotClient.crm.objects.associationsApi.create(contact_id,found_company_id,"HUBSPOT_DEFINED",1,"contact_to_company")
The function expects individual arguments, not an object. See example documentation.