One or more associations are not valid when creating deal

Hello!

Have trouble with assotiating contact to deal. I try to create deal using POST crm/v3/objects/deals API with next associations array

"associations": [
 {
 "to": {
 "id": 3101
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 3
 }
 ]
 }
 ],

And I getting an error:

{
 "status": "error",
 "message": "one or more associations are not valid",
 "correlationId": "6e479ecb-245a-4c4b-9071-ffed833b6683",
 "category": "BAD_REQUEST"
}

May be exists some ways to get more accurate error? Because contact id is 100% correct

Hey, @DEgiptsev :waving_hand: Thanks for reaching out. I tried a similar request using the on-page example to Create a DealPOST/crm/v3/objects/deals

Request:

curl --request POST \
 --url https://api.hubapi.com/crm/v3/objects/deals \
 --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
 --header 'content-type: application/json' \
 --data '{
 "properties": {
 "amount": "250.00",
 "closedate": "2023-12-07T16:50:06.678Z",
 "dealname": "Stunt helmets for cats",
 "dealstage": "presentationscheduled",
 "hubspot_owner_id": "198670650",
 "pipeline": "default"
 },
 "associations": [
 {
 "to": {
 "id": "901"
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 3
 }
 ]
 }
 ]
}'

Response:

HTTP 201

{
 "id": "13149364401",
 "properties": {
 "amount": "250.00",
 "amount_in_home_currency": "250.00",
 "closedate": "2023-12-07T16:50:06.678Z",
 "createdate": "2023-04-26T16:23:08.110Z",
 "days_to_close": "225",
 "dealname": "Stunt helmets for cats",
 "dealstage": "presentationscheduled",
 "hs_all_accessible_team_ids": "12073943",
 "hs_all_owner_ids": "198670650",
 "hs_all_team_ids": "12073943",
 "hs_closed_amount": "0",
 "hs_closed_amount_in_home_currency": "0",
 "hs_createdate": "2023-04-26T16:23:08.110Z",
 "hs_deal_stage_probability_shadow": "0.59999999999999997779553950749686919152736663818359375",
 "hs_forecast_amount": "250.00",
 "hs_is_closed": "false",
 "hs_is_closed_won": "false",
 "hs_is_deal_split": "false",
 "hs_lastmodifieddate": "2023-04-26T16:23:08.110Z",
 "hs_object_id": "13149364401",
 "hs_projected_amount": "0",
 "hs_projected_amount_in_home_currency": "0",
 "hs_user_ids_of_all_owners": "10233975",
 "hubspot_owner_assigneddate": "2023-04-26T16:23:08.110Z",
 "hubspot_owner_id": "198670650",
 "hubspot_team_id": "12073943",
 "pipeline": "default"
 },
 "createdAt": "2023-04-26T16:23:08.110Z",
 "updatedAt": "2023-04-26T16:23:08.110Z",
 "archived": false
}

In this case, it’s hard to say what the root cause is. The endpoint in a simple form (using the on-page example) works as expected. Can you share your full request?

Best,

Jaycee

Hey, @Jaycee_Lewis, sure, there is full request:

{
 "properties": {
 "dealname": "test",
 "closedate": "2023-04-21T13:04:27.941Z",
 "dealtype": "existingbusiness",
 "gross_price": 0,
 "amount": 0,
 "deal_currency_code": "GBP",
 "closed_won_reason": "Online booking (website checkout)",
 "dealstage": "closedwon"
 },
 "associations": [
 {
 "to": {
 "id": 3101
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 3
 }
 ]
 }
 ]
}