Deals API Documentation Troubles

SOLVE
Occasional Contributor

I have just resolved a bitter struggle with the Hubspot Deal Create API .     I wrote a spiff-a-rino Python program to create deals, companies, and contacts, using a parameter file to hold the details of the REST calls and other files to hold the JSON payloads.  Everything worked great except for the Deal Creation part.  That failed with an "HTTP Error 400: Bad Request" error. 

 

After exhaustively checking my params, and code, I tried cutting and pasting the example Python code from the documentation into a script and running that.  That also failed with an Error 400.  I could create a Deal through the actual website without trouble. 

 

After much struggle and misery, I learned the following things:

 

  •  An unknown property in the JSON payload will give you an Error 400: Bad Request. If you edit the JSON payload for a new company and put "{"name":"foo","value":"bar"}, into your JSON payload, you'll get the 'bad request' error, even though the JSON parses correctly.  A hint in the error body that the problem is an unknown property would've saved me several hours of hair-tearing.

 

  • HubSpot does not currently know the "hubspot_owner_id" property referenced in the example code for creating a deal.  Thus, the example code fails with an error 400 and no hint of why the error occurred.

 

Beware of this when creating deals. 

 

As an aside, you'll also have to figure out the REST endpoint for creating a deal property, as the documentation page  doesn't actually tell you what it is explicitly.  I made this work with the URL "https://api.hubapi.com/properties/v1/deals/properties".  Not too hard to figure out, but still..

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Highlighted
Occasional Contributor

I Am Enlightened!  As Mr. Willson graciously explained in a DM, the trouble turned out to be _not_ the 'hubspot_owner_id" name itself, but rather that I was passing the _label_ ( that is, my email address) in the Value field, rather than Hubspot's internal id number for that person.  I found the internal id by going to   Settings/Properties/Deal Properties/Deal Owner, then looking at the "Internal Value" field rather than the "Label" field for the email address I wanted to insert in my deal.  I suspect that the root of the trouble was that HubSpot was expecting a numeric value in that field, rather than a string, so it dumped the whole transaction.

 

A bonus!  When I passed the correct value, I got an automated email telling me that I had been assigned the newly created Deal.

 

 

7 Replies 7
Highlighted
HubSpot Moderator

Hi @CHS_Annuitas 

 

Thanks for this feedback when using this documentation, i'll be sure to review and pass this onto our team internally! 

 

I'd like to ask about your 2nd point in relation to the hubspot_owner_id however. I can successfully use this sample code when creating my deal without an error being thrown. To confirm, this hubspot_owner_id property maps across to the internal property, Deal Owner. When making this call, it is important that you pass an Id that is associated to an Owner in this property. 

 

Lastly, in the last documentation you linked for Creating a Deal Property, the endpoint which is required to be used can be found underneath the Optional Parameters section. 

 

I hope this helps!

Matthew Willson

HubSpot Developer Support
Highlighted
Occasional Contributor

Well!  Now I am very intrigued!  I am working from a bog-standard free developer account, and it clearly shows a "Deal Owner" property.  When I create a deal from the API, of course, that property comes up blank.  I can set it from the web page without any trouble. 

 

I just tried this again with a payload with and without the "hubspot_owner_id" and got exactly the same results as my original post.  I found the 'internal property name'  here ( https://app.hubspot.com/property-settings/7063355/properties?action=edit&property=hubspot_owner_id&t... ) and verified that "hubspot_owner_id" is in fact the internal name as you said.    I'll try setting that property through the edit API later today and update with my adventures. 

 

BTW you right about the properties endpoint.  I was slightly confused 'cause it wasn't highlighted at the top of the doc page as it is in other API pages.

 

Reply
0 Upvotes
Highlighted
Occasional Contributor

Okay, that was pretty interesting.  I tried updating a deal.  After figuring out that the deal update REST call requires a "PUT" method, unlike the other REST calls which use "POST", and then updating my code accordingly, I got this to work ok fine. 

The response I get back from a successful deal update API call clearly shows the "hubspot_owner_id", along with its associated timestamp, value, and versions[] list.

 

And when I try to update it even with the same value it already holds, I **still** get an error 400 ( Bad Request ).  So at least my trouble is consistent.

 

Reply
0 Upvotes
Highlighted
HubSpot Moderator

Hi @CHS_Annuitas 

 

Thanks for getting back with your findings! Would you be able to provide me with the Request URL and responses you're getting when you initially fetch the <code>hubspot_owner_id</code> and when you attempt to update this.

 

Matthew Willson

HubSpot Developer Support
Reply
0 Upvotes
Highlighted
Occasional Contributor

Uh hmm.   I only have a free dev account, but I am still a little leery of publishing my API key on what is essentially a public forum.    Can we do this over a more private channel?

 

Reply
0 Upvotes
Highlighted
HubSpot Moderator

Hey @CHS_Annuitas 

 

You're absolutely correct to feel a little 'leery' there, apologies. I should have stated this in my request, when posting on forums, we do always recommend removing API Keys from your requests you pass over.

 

However, if you'd like, you can also DM me with the requested details. 

 

Thanks!

 

 

Matthew Willson

HubSpot Developer Support
Reply
0 Upvotes
Highlighted
Occasional Contributor

I Am Enlightened!  As Mr. Willson graciously explained in a DM, the trouble turned out to be _not_ the 'hubspot_owner_id" name itself, but rather that I was passing the _label_ ( that is, my email address) in the Value field, rather than Hubspot's internal id number for that person.  I found the internal id by going to   Settings/Properties/Deal Properties/Deal Owner, then looking at the "Internal Value" field rather than the "Label" field for the email address I wanted to insert in my deal.  I suspect that the root of the trouble was that HubSpot was expecting a numeric value in that field, rather than a string, so it dumped the whole transaction.

 

A bonus!  When I passed the correct value, I got an automated email telling me that I had been assigned the newly created Deal.