I need to set multiple associations between a Contact and a Company via a workflow using the API
I have a contact that I need to mark as PrimaryContact and BillingContact. This works fine via the Hubspot UI, but when I try to set an additional association via the API it overwrites the first association
The example below results in 1 association against the company
const fromObjectType = "companies";const fromObjectId = companyToAssociate;const toObjectType = "contact";const toObjectId = contactIdToAssociate;
const AssociationSpec = [ { "associationCategory": "USER_DEFINED", "associationTypeId": 124, }];const createContactAssociationResponse = await hubspotClient.apiRequest({ method: 'PUT', path: /crm/v4/objects/${fromObjectType}/${fromObjectId}/associations/${toObjectType}/${toObjectId}, body: AssociationSpec});const AssociationSpec2 = [ { "associationCategory": "USER_DEFINED", "associationTypeId": 113, }];const createContactAssociationResponse2 = await hubspotClient.apiRequest({ method: 'PUT', path: /crm/v4/objects/${fromObjectType}/${fromObjectId}/associations/${toObjectType}/${toObjectId}, body: AssociationSpec2});