APIs & Integrations

Jeremy_Craven
Member

Deal Creation with Associated Company and Contact

I am making a call to the deals API to create a new deal that is very similar to the example request in the documentation here (https://developers.hubspot.com/docs/methods/deals/create_deal). I am passing in a single company id and a single contact id similar to the example request shown.

02%20PM

The newly created deal is always only associated to the company and has no associated contacts even though I put a contact id to associate with in the request. However, for a contact with no company, the deal is created and is correctly associated to the contact. Any help on why the deal creation endpoint will not associate to both a company and contact would be appreciated. Thanks.

0 Upvotes
4 Replies 4
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Deal Creation with Associated Company and Contact

Hi @Jeremy_Craven,

That's exceedingly strange; that request body should work just fine. I did some testing, and I was able to create a deal with (almost) that exact request body here:
https://app.hubspot.com/contacts/4747149/deal/329511461/?interaction=note

Can you give me some more info on the code making this request? I'm wondering if the vid being included is somehow missing or malformed?

Jeremy_Craven
Member

Deal Creation with Associated Company and Contact

It was indeed an issue with the code that created the request. Thanks for your help.

Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Deal Creation with Associated Company and Contact

Hi @Jeremy_Craven,

I'm not able to reproduce this on my end; can you give me more info on the response you're seeing, and perhaps links to an example contact/company record you're seeing association issues with?

0 Upvotes
Jeremy_Craven
Member

Deal Creation with Associated Company and Contact

This is an example request I made below.

  {
      "associations": {
        "associatedCompanyIds": [
          872312334
        ],
        "associatedVids": [
          301
        ]
      },
      "properties": [
        {
          "value": "Test Deal",
          "name": "dealname"
        },
        {
          "value": "appointmentscheduled",
          "name": "dealstage"
        },
        {
          "value": "default",
          "name": "pipeline"
        },
        {
          "value": "32956039",
          "name": "hubspot_owner_id"
        },
        {
          "value": 1540492798968,
          "name": "closedate"
        }
      ]
    }

Here is an example response below. As you can see, the associatedCompanyIds have the company associated to the deal. However, associatedVids is empty even though my request included an id.

{
   "portalId":4747149,
   "dealId":327303404,
   "isDeleted":false,
   "associations":{
      "associatedVids":[

      ],
      "associatedCompanyIds":[
         872312334
      ],
      "associatedDealIds":[

      ]
   },
   "properties":{
      "pipeline":{
         "value":"default",
         "timestamp":1532716798982,
         "source":"API",
         "sourceId":"userId=6233477",
         "versions":[
            {
               "name":"pipeline",
               "value":"default",
               "timestamp":1532716798982,
               "sourceId":"userId=6233477",
               "source":"API",
               "sourceVid":[

               ]
            }
         ]
      },
      "dealname":{
         "value":"Harry's Company",
         "timestamp":1532716798982,
         "source":"API",
         "sourceId":"userId=6233477",
         "versions":[
            {
               "name":"dealname",
               "value":"Harry's Company",
               "timestamp":1532716798982,
               "sourceId":"userId=6233477",
               "source":"API",
               "sourceVid":[

               ]
            }
         ]
      },
      "hubspot_owner_id":{
         "value":"32956039",
         "timestamp":1532716798982,
         "source":"API",
         "sourceId":"userId=6233477",
         "versions":[
            {
               "name":"hubspot_owner_id",
               "value":"32956039",
               "timestamp":1532716798982,
               "sourceId":"userId=6233477",
               "source":"API",
               "sourceVid":[

               ]
            }
         ]
      },
      "closedate":{
         "value":"1540492798968",
         "timestamp":1532716798982,
         "source":"API",
         "sourceId":"userId=6233477",
         "versions":[
            {
               "name":"closedate",
               "value":"1540492798968",
               "timestamp":1532716798982,
               "sourceId":"userId=6233477",
               "source":"API",
               "sourceVid":[

               ]
            }
         ]
      },
      "hs_lastmodifieddate":{
         "value":"1532716798982",
         "timestamp":1532716798982,
         "source":"CALCULATED",
         "sourceId":null,
         "versions":[
            {
               "name":"hs_lastmodifieddate",
               "value":"1532716798982",
               "timestamp":1532716798982,
               "source":"CALCULATED",
               "sourceVid":[

               ]
            }
         ]
      },
      "hubspot_owner_assigneddate":{
         "value":"1532716798982",
         "timestamp":1532716798982,
         "source":"API",
         "sourceId":"userId=6233477",
         "versions":[
            {
               "name":"hubspot_owner_assigneddate",
               "value":"1532716798982",
               "timestamp":1532716798982,
               "sourceId":"userId=6233477",
               "source":"API",
               "sourceVid":[

               ]
            }
         ]
      },
      "dealstage":{
         "value":"appointmentscheduled",
         "timestamp":1532716798982,
         "source":"API",
         "sourceId":"userId=6233477",
         "versions":[
            {
               "name":"dealstage",
               "value":"appointmentscheduled",
               "timestamp":1532716798982,
               "sourceId":"userId=6233477",
               "source":"API",
               "sourceVid":[

               ]
            }
         ]
      },
      "hs_createdate":{
         "value":"1532716798982",
         "timestamp":1532716798982,
         "source":"API",
         "sourceId":"userId=6233477",
         "versions":[
            {
               "name":"hs_createdate",
               "value":"1532716798982",
               "timestamp":1532716798982,
               "sourceId":"userId=6233477",
               "source":"API",
               "sourceVid":[

               ]
            }
         ]
      },
      "createdate":{
         "value":"1532716798982",
         "timestamp":1532716798982,
         "source":"API",
         "sourceId":"userId=6233477",
         "versions":[
            {
               "name":"createdate",
               "value":"1532716798982",
               "timestamp":1532716798982,
               "sourceId":"userId=6233477",
               "source":"API",
               "sourceVid":[

               ]
            }
         ]
      }
   },
   "imports":[

   ],
   "stateChanges":[

   ]
}
0 Upvotes