Deal creation API - response is 200, but the deal is not created
SOLVE
Hello,
I am trying to create a deal using the following python code.
I get a response code 200, but the deal does not appear in the portal (I have no filters).
The code result is: "Done. Success: True"
What am I missing?
Thanks a lot in advance!
Deal creation API - response is 200, but the deal is not created
SOLVE
Yes, the only difference between a working request and a failing request was the content-type header.
Requests to Contacts API work fine also without the content-type header.
For example the following works fine:
r1 = requests.post('https://api.hubapi.com/contacts/v1/contact/?hapikey=' + apiKey, data=json.dumps(contact))
I'll investigate the 200 responses; was the only difference between a working request and a failing request the content-type header? The content-type header is required for all the HubSpot APIs; it's almost always application/json, but for some endpoints (e.g. form submission, upload a file) it's a different content type.
Deal creation API - response is 200, but the deal is not created
SOLVE
Yes, the only difference between a working request and a failing request was the content-type header.
Requests to Contacts API work fine also without the content-type header.
For example the following works fine:
r1 = requests.post('https://api.hubapi.com/contacts/v1/contact/?hapikey=' + apiKey, data=json.dumps(contact))
Are you using the hapikey obtained from your test or production Marketing/CRM portal? Or are you using the hapikey obtained from your developer portal? You'll need to make sure you're using the one from your Marketing/CRM portal. Additionally, are you seeing the resulting deal JSON in the response? Can you send me the full response body you get?
Without the headers, the response code was 200, the result was coming empty - with no json, and the deal was NOT created.
I believe this is a bug of the HubSpot API.
The API should not respond 200 if there is a problem. However, when the response code is 200, the deal must be created.
Also, there is an inconsistency - some API do not require headers, and some do.