APIs & Integrations

VBalazs
Member

Deleting an associationType between a Custom Object and a Company Object will delete all Association

Hello,

 

I've a custom object, and a company object, and multiple associations between them. I believe in the UI it's called labels, but in the API it's called associationType. So I've multiple association types between a custom object, and a company object, and I'd like to delete one of them, so I call the 

{{hubspot-api-url}}/crm/v3/objects/:objectType/:objectId/associations/:toObjectType/:toObjectId/:associationType

 

endpoint. 

 

Providing the correct associationType all of the associations are deleted, not just the one I've asked for.

 

Tried with hubspot js library, and by calling the API with postman, and got the same result.

 

So I think it's a kind of a bug in the API

 

I know I could just list all the associations, and recreate them... but it feels not right.

 

 

4 Replies 4
ep_ts
Member

Deleting an associationType between a Custom Object and a Company Object will delete all Association

its been almost a year and this hasent had any attention or confirmation from hubspot. this bug is still there.

0 Upvotes
paulem
Participant

Deleting an associationType between a Custom Object and a Company Object will delete all Association

I have the same issue and can't find the solution. It seems to work in the UI, but this uses the v1 api...

0 Upvotes
VBalazs
Member

Deleting an associationType between a Custom Object and a Company Object will delete all Association

Hi,

 

I ended up getting all the associations, with the v4 API endpoint:

const response = client.apiRequest({
  method: 'GET',
  path: `/crm/v4/objects/${customObjectType}/${id}/associations/${contactObjectType}`,
});

 

selected the associations to my specific contact from the response:

const associations = await response.json();
let current = associations.results.find(
  (record: any) => record.toObjectId.toString() === contactId,
)?.associationTypes || [];

modified the associations, deleted, added new ones, then updated:

await client.apiRequest({
  method: 'PUT',
  path: `/crm/v4/objects/${customObjectType}/${id}/associations/${contactObjectType}/${contactId},
  body: current,
});

 Note that if you want to delete all associations at the end, better call:

client.apiRequest({
  method: 'DELETE',
  path: `/crm/v4/objects/${customObjectType}/${executiveAssistantId}/associations/${contactObjectType}/${contactId}`,
});

 

Regards

Balazs

VBalazs
Member

Deleting an associationType between a Custom Object and a Company Object will delete all Association

Hi,

 

I think it's still a bug in this api endpoint, can somebody tell me where can I fill a bug ticket?

 

Thanks

Balazs

 

0 Upvotes