Create association between custom object and contacts via API

Hi,

We are trying to associate a contact to a custom object in HubSpot by using Power Automate and Hubspot API. We have set up a private app and Power Automate and tested, that it works.

Our custom object is an Event, the object type id is 2-119772789, an the one we are using in the URI. The specific event id is 5229127388 where we want to associate the contact record id 2803.

We are using the following URI: https://api.hubapi.com/crm/v3/associations/2-119772789 /Contacts/batch/create

In the body we are having the following raw Json code:

{

“‘Input’”: [

“‘from’”, {

“hs_object_id”: “The record ID for the event”

},

“‘to’”, {

“hs_object_id”: “The record ID for the contact”

},

“‘types’”, {

“associationTypeId”: “70”

}

]

}

When using a POST command we get the following result, all over status is “201 created”:

{

“status”: “COMPLETE”,

“results”: [],

“startedAt”: “2024-07-09T11:49:51.182Z”,

“completedAt”: “2024-07-09T11:49:51.222Z”

}

Looking into HubSpot the contact above has not been associated with the Event.

Then we tried to changed POST into PUTT, but now we got the status “405 Method Not Allowed”

Anyone that can guide us from here, so we will be able to make the associations within a flow in Power Automate instead of adding each contact to an event manually in HubSpot.

Best regards,

Sanne

Hi @SLEisig,

Thank you for contacting the Community!

Allow me to consult a few HubSpot experts for some insights: Hello @TDwebdev, @Jnix284, @Anton - Would you kindly share any recommendations for @SLEisig?

We deeply value your contributions!

Thanks,

Diana

Hi @DianaGomez,

Thanks for tagging som HubSpot experts for some insights, hope that someone will be able to share any recommendations.

Br. @SLEisig

Thanks for the tag @DianaGomez, I’m sorry for the delayed response this was buried in my inbox.

@SLEisig I don’t have the answer to your question, but I have found a lot of success troubleshooting API issues with Hub Helper Harry, a chatGPT based bot that was built by @nlafakis / @Nico_Lafakis (not sure which is his current profile)

Thank you very much for your suggestion of using Hub Helper Harry, I will try to go that way, hoping to find a solution. I had tried CoPilot, but it wasn’t that helpful.

Hi,

Take a look at this post AI Agents for B2B Revenue Teams

We had similar challenges with assosiations too.

Hope it help!

Krystian

@Jnix284 Again many thanks for your recommendation. I used Hub Helper Harry and got the answer that it was the JSON structure that caused the issue. The corrected JSON body that Hub Helper Harry suggested was working perfectly and I have now been able to to associate a contact to a custom object in HubSpot by using Power Automate and Hubspot API.