Getting 400 on insert deals

Hi, getting 400 error while inserting deals using v3 API. Can anyone help on this thanks.
Error: {“status”:“error”,“message”:“Invalid input JSON on line 1, column 18: Cannot deserialize value of type `java.util.ArrayList<com.hubspot.crmpublic.core.models.associations.PublicAssociationsForObject>` from Object value (token `JsonToken.START_OBJECT`)”,“correlationId”:“5929f674-90e1-4797-a9ef-dc3a37d53b20”}

Hey @MPrasad9

Are you able to reply with your JSON payload? You can redact some information if you need. We will need that to help diagnose your issue.

Regards,
-T

Hi @tominal , Below is the payload which we sent

{
“associations”: {
“company”: {
“ids”: “2664404286”
}
},
“properties”: {
“amount”: 294,
“createdate”: 1671067793063,
“dealname”: "Urban Sync (Business to Enterprise) ",
“expansion_type”: “Uplift: BE > EE”,
“hubspot_owner_id”: “51651368”,
“pipeline”: “788269”
}
}

Hi @tominal,

Below is the payload which we sent, can you check this thanks

{
“associations”: {
“company”: {
“ids”: “2664404286”
}
},
“properties”: {
“amount”: 294,
“createdate”: 1671067793063,
“dealname”: "Urban Sync (Business to Enterprise) ",
“expansion_type”: “Uplift: BE > EE”,
“hubspot_owner_id”: “51651368”,
“pipeline”: “788269”
}
}

Hey @MPrasad9,

Apologies, I wrote up a response to this, but it must have been lost.

The gist of it was that you are not able to pass associations in your POST request like that. You will have to follow the steps:

  1. Insert your deal record which will return a Deal ID in the response
  2. Use that Deal ID in a separate POST request to the Associations API

Your deal payload would look like:

/crm/v3/objects/deals

{
 "properties": {
 "amount": 294,
 "createdate": 1671067793063,
 "dealname": "Urban Sync (Business to Enterprise) ",
 "expansion_type": "Uplift: BE > EE",
 "hubspot_owner_id": "51651368",
 "pipeline": "788269"
 }
}

And then your associations API request would look like:

/crm/v3/associations/deals/companies/batch/create

{
 "inputs": [
 {
 "from": {
 "id": "<INSERT DEAL ID HERE>"
 },
 "to": {
 "id": "2664404286"
 },
 "type": "deal_to_company"
 }
 ]
}

Hope that helps!

Hi @tominal , Thanks. Its very helpful