Having an issue using the Delete specific labels api endpoint

Hi, I’m having issues with the following api when testing on Postman:

/crm/v4/associations/{fromObjectType}/{toObjectType}/batch/labels/archive

So, I having issues with removing an association label from a custom created association. I’m using the apiRequest method to call the api.

await hubSpotClient
 .apiRequest({
 method: 'POST',
 path: `/crm/v4/associations/${customObjectTypeId}/${contactObjectTypeId)}/batch/labels/archive`,
 headers: {
 accept: 'application/json',
 authorization: `Bearer ${auth}`,
 },
 body: {
 associationCategory: 'USER_DEFINED',
 associationTypeId: associationTypeId,
 fromObjectId: customObjectId,
 toObjectId: contactId,
 },
 })

The api call brings back a 204 response, but when I check on Hubspot the label hasn’t been removed. I also tried testing on Postman and got the same result. A 204 response and the label not being removed.

Hi @SNgantweni

I hope this code can solve your query

await hubSpotClient.apiRequest({
method: ‘POST’,
path: `/crm/v4/associations/${customObjectTypeId}/${contactObjectTypeId}/batch/labels/archive`,
headers: {
accept: ‘application/json’,
authorization: `Bearer ${auth}`,
},
body: {
associationCategory: ‘USER_DEFINED’,
associationTypeId: associationTypeId,
fromObjectId: customObjectId,
toObjectId: contactId,
},
});

Hope this will helps you out. Please mark it as Solution Accepted & Upvote to help other Community member.
Thanks!

Hi Gaurav, thank you for replying. Unfortunately I’m still getting the same issue.

Hi @SNgantweni

I think you should use the “PUT” method

for example

Example PUT URL:
https://api.hubapi.com/crm-associations/v1/associations/delete

Example PUT JSON, removing the association from a contact with vid 25 to a ticket with ID 100:
{
“fromObjectId”: 25,
“toObjectId”: 100,
“category”: “HUBSPOT_DEFINED”,
“definitionId”: 15
}

Returns a 204 No Content response on success.

Refer to the link below for more information