Apologies in advance for formatting - tried to have everything nicely presented in code blocks but it was failing verification upon submitting the post for some reason.
I’m trying to set up an automation that creates a deal that is linked to a contact. It’s a rails app so using the hubspot-api-ruby gem . Here is an example of the request:
properties = {:dealname=>"Sample name", :upsell_interest=>"Interested", :amount=>239, :pricing_calc__team_size_=>"1 - 4 team members", :dealstage=>48189289}}
associations = [{ types: [{ associationCategory: "HUBSPOT_DEFINED", associationTypeId: DEAL_TO_CONTACT }], to: { id: contact_id } }]
body = { associations: associations, properties: properties }
with_rescue(error: Hubspot::Crm::Deals::ApiError) do
api_response = api_client.crm.deals.basic_api.create(body: body)
api_response
I have tried using this setup on a dev hubspot account and it works perfectly. When I try and use it on my production hubspot account it fails with a ‘one or more associations are not valid’
I’ve tried querying what assocations are present between deals and contacts using
https://api.hubapi.com/crm/v4/associations/deals/contacts/labels
and it returns
{“results”:[{“category”:“USER_DEFINED”,“typeId”:1,“label”:“Primary contact”},{“category”:“HUBSPOT_DEFINED”,“typeId”:3,“label”:null}]}
I’ve tried switching the arguments over to USER_DEFINED with typeId 1 but it still fails with the same error.
Any ideas on what’s going wrong here? I’m confused as to why this works on my dev hubspot but not my production one
EDIT
Querying this a bit more I have managed to get a more detailed error response:
{
“status”: “error”,
“message”: “one or more associations are not valid”,
“correlationId”: “4fffb907-e7ea-4a7f-8295-f49afa966647”,
“errors”: [
{
“message”: “0-1=85245631516 is not a valid object”,
“context”: {
“validationResult”: [
“INVALID_FROM_OBJECT”
]
}
}
],
“category”: “BAD_REQUEST”
}
To my understanding of hubspot’s record system, 85245631516 is a valid instance of type contact (0-1). So still confused as to why it’s failing but hopefully helpful to someonehere