Hi,
I am using power automate to create a contact and a deal and it all works fine.
However, the two are not linked, and this is where I am hitting a brick wall. I am trying to create the association between the two, I am using the “create a default association” as an action in powerautomate, and I have set the parameters for the From/To object types and ID’s. and the code looks fine :
{
“fromObjectType”: “contacts”,
“fromObjectId”: “224557309139”,
“toObjectType”: “deals”,
“toObjectId”: “152506565856”
}
(I have also tried using the object type ID as well i.e 0-3)
When I run the flow the contact and deal is set up, but it hits a problem with making this association and gives the error message :
The API operation ‘CreateDefault’ requires the property ‘body/results/0/associationSpec/associationTypeId’ to be of type ‘String’ but is of type ‘Integer’.’
Powerautomate gives me no access to the associationTypeId so I can’t understand how I can fix this?
Any help would be appreciated.
Hey, @TWilliams222
Thanks for your post. I’ve noticed that PA questions don’t get a lot of traction here. This is not because of anything you did, there are just a few topics where there aren’t as many experts who post here. If you don’t get a reply here, you might try over at the PA forums. I found one related post there, but I am not sure if the solution from 2023 is current or now outdated.
Best,
Jaycee
Thank you, I will take a look.
@TWilliams222, I always run into issues with the existing connector, so by default I use HTTP requests or custom connectors. The HTTP request route is really straightforward, here’s how you can do it.
- Set up a HubSpot Private App and make sure it has the below scopes. I have an article that explains this in detail, check out the first half.
- crm.objects.contacts.read/write
- crm.objects.deals.read/write
- Store the generated token in something like Azure Key Vault, or hardcode it if you’re testing.
- In Power Automate, create the contact first using an HTTP POST to: https://api.hubapi.com/crm/v3/objects/contacts
- Parse the response to grab the contact ID
- Create the deal, and inside the deal creation request, include the association
Screenshots after a test:
HTTP: create contact
Endpoint (URI):
https://api.hubapi.com/crm/v3/objects/contacts
{
"properties": {
"firstname": "Jane",
"lastname": "Smith",
"email": "jane.smith@example.com",
"company": "Example Corp"
}
}
Parse contact JSON
- Content:
- body(‘HTTP:_create_contact’)
- Schema:
{
"type": "object",
"properties": {
"id": {
"type": "string"
}
},
"required": [
"id"
]
}
Notes:
- Replace @{outputs(‘Get_secret’)?[‘body/value’]} with a your Private App access token.
- Ensure required contact properties (e.g., email) are included based on your HubSpot portal settings.
HTTP: create deal and associate with contact
- Endpoint (URI):
- Method:
- Headers:
- Body:
{
"properties": {
"dealname": "New Website Project",
"dealstage": "24102e92e-bac0-4fb1-9782-5aca4b6a7dc5",
"pipeline": "813fa467-8752-4e27-99b0-f5c5beecc9a0",
"amount": "15000",
"closedate": "@{div(sub(ticks(startOfDay(utcNow())), 621355968000000000), 10000)}",
"dealtype": "newbusiness",
"description": "Website redesign for Example Corp",
"hubspot_owner_id": "656431197"
},
"associations": [
{
"to": {
"id": "@{body('Parse_contact_JSON')['id']}"
},
"types": [
{
"associationCategory": "HUBSPOT_DEFINED",
"associationTypeId": 3
}
]
}
]
}
Notes:
- Replace @outputs(‘Get_secret’)?[‘body/value’]} with your Bearer access token.
- closedate must be a valid ISO 8601 format datetime string (e.g., “2025-06-05T12:00:00.000Z” OR “2025-06-05”).
- Replace @{body(‘Parse_contact_JSON’)[‘id’]} with the actual contact ID you wish to associate the deal with.
- associationTypeId: 3 is the default for Deal to Contact association in HubSpot.