APIs & Integrations

karien
Participant

add Label (do not overwrite existing label)

SOLVE

is there a way to ADD a label to an already existing association

 

for example. i have JOHN, he associated to my record with Label "contact person" 
now via custom code ADD another label to the same record. example "photographer"
im assigning labels via custom code action all the time. but have to do complicated checks to see whether John is both contact person and photographer. 
is there a way to ADD/Patch another label? 

1 Accepted solution
WesQ
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

add Label (do not overwrite existing label)

SOLVE

Hello! @karien 

 

Referencing the documentation on Associations v4 API

It seems we can only do a PUT method.  There was no PATCH method provided for this. 

As a workaround, what I do is I simply add the existing associationTypeId (which will get overwritten), and include another associationTypeId that we want to add,  just like this: 

 

PUT request to https://api.hubapi.com/crm/v4/objects/contact/{objectId}/associations/deal/{toObjectId}
Authorization: Bearer pat-******************************
Content-Type: application/json

 

 

 

[
{
"associationCategory": "USER_DEFINED",
"associationTypeId": 247 // For example if this is the Id for "Contact Person"
},
{
"associationCategory": "USER_DEFINED",
"associationTypeId": 232 // We just add another Id for "Photographer"
}
]

 

 


 

Was I able to help answer your question? Help the community by marking it as a solution.

View solution in original post

0 Upvotes
3 Replies 3
WesQ
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

add Label (do not overwrite existing label)

SOLVE

Hello! @karien 

 

Referencing the documentation on Associations v4 API

It seems we can only do a PUT method.  There was no PATCH method provided for this. 

As a workaround, what I do is I simply add the existing associationTypeId (which will get overwritten), and include another associationTypeId that we want to add,  just like this: 

 

PUT request to https://api.hubapi.com/crm/v4/objects/contact/{objectId}/associations/deal/{toObjectId}
Authorization: Bearer pat-******************************
Content-Type: application/json

 

 

 

[
{
"associationCategory": "USER_DEFINED",
"associationTypeId": 247 // For example if this is the Id for "Contact Person"
},
{
"associationCategory": "USER_DEFINED",
"associationTypeId": 232 // We just add another Id for "Photographer"
}
]

 

 


 

Was I able to help answer your question? Help the community by marking it as a solution.

0 Upvotes
karien
Participant

add Label (do not overwrite existing label)

SOLVE

HI WesQ, thx, this what im currently doing, but i first then have to determne what the "current" label/s is. (there are many), filter/loop through them all, because one contact can have more than one label ALREADY. then use the results to add my Added label with all the previous ones also. I was just hoping i could just keep the contact with it's current labels, en "Patch" another label also.
but thank you, you confirmed this is not possible, IF I understood you correctly....

WesQ
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

add Label (do not overwrite existing label)

SOLVE

Yeah that's exactly what I would do too in that scenario.  I agree, a PATCH endpoint would definitely be useful.  Maybe HubSpot is adding that later.

0 Upvotes