Contact does not get updated for existing deal

Analyst
Member

I'm trying to integrate hubspot with our inventory management software system
I've created a sale in HubSpot via API with Contact (AssociatedVid: 12801).
After that I changed sale's customer in our inventory system end and try to update the deal in HubSpot.
I sent the Put request with new AssociatedVid: 4301, but got a response with old AssociatedVid: 12801.
I checked in HubSpot UI, the contact in deal is not updated.
How can I update contact for existing deal via HubSpot API?

 

image_2020_04_08T06_27_25_681Z.pngimage_2020_04_08T06_26_32_163Z.png

0 Upvotes
7 Replies 7
Willson
HubSpot Employee

Hey @Analyst 

 

I am unable to determine which endpoint you're hitting here but seeing as how you mention that you're updating a Deal, I will assume it is our Update a Deal endpoint seen here.

 

As per the documentation, the Method and endpoint are as follows:

PATCH/crm/v3/objects/deals/{dealId}

Can you confirm that you're hitting this endpoint? Looking at your code, it appears the method you're using is PUT instead of PATCH too, can you attempt to update this to see if this resolves the issue?

 

I hope this helps!

Product Expert | Customer Support
HubSpot
0 Upvotes
Analyst
Member

Hi Matthew, thank you for your response, We use this endpoint: https://api.hubapi.com/deals/v1/deal (looks like version 1).
https://developers.hubspot.com/docs/methods/deals/update_deal

 

Could you advice how to update a deal contact through API version 1?

0 Upvotes
Willson
HubSpot Employee

Hey @Analyst 


Thanks for clarifying here! I've just tested the endpoint and can confirm that it is working from my end.

 

Can you confirm that your payload you're passing is 

"Content-Type": "application/json"

This is a required config in order to work with this endpoint.

 

I hope this helps!

Product Expert | Customer Support
HubSpot
0 Upvotes
Analyst
Member

yes, sure, we double checked it through Fiddler, we send "Content-Type": "application/json"

 

image_2020_04_09T05_07_08_305Z.png

0 Upvotes
Willson
HubSpot Employee

Hey @Analyst 

 

Looking at your screenshot, your Request Headers are showing that you're POST'ing data rather than using PUT as your method. 


Am I interpreting these results correctly, please do correct me if I am mistaken.

 

Product Expert | Customer Support
HubSpot
0 Upvotes
Analyst
Member

Hi Willson, the last screen just showed that we use application/json content-type.

On the first screenshot you can see that we use put request for updating existing deals.

image_2020_04_10T07_30_08_227Z.pngimage_2020_04_10T07_29_51_434Z.png

here you can see that we send a request with company and vid associations and receive a response with empty associations. 

Let's run another test.

 

image_2020_04_10T07_35_16_893Z.pngimage_2020_04_10T07_35_05_361Z.png

here you can see that we create a new deal with using post request and everything is fine, we received vid association in response

after that we tried to update the deal with put-request

image_2020_04_10T07_37_54_575Z.png

send a new associations, but receive the old associatedVid

image_2020_04_10T07_38_24_256Z.png

this is the problem. 

0 Upvotes
Willson
HubSpot Employee

Hi @Analyst 

 

Thanks for the detail here! Looking into the details it appears you're attempting to update the Associations via the Deals endpoint which is not currently possible. 

 

This must be done via the use of our Associations API which can be found here. In this case, when updating the associations a new call will be made. For example, if we add a new association between the Deal and a Contact, we'd use the following request:

Request:
PUT https://api.hubapi.com/crm-associations/v1/associations?hapikey=demo

Body:
{
  "fromObjectId": DEAL_ID,
  "toObjectId": CONTACT_ID,
  "category": "HUBSPOT_DEFINED",
  "definitionId": 3
}

You can find the HUBSPOT_DEFINED values per the table definitions on the overview linked above.

 

I hope this helps!

Product Expert | Customer Support
HubSpot
0 Upvotes