companies creation API: bad property error message is corrupted

btsp
Contributor
I am trying to use the API /companies/v2/companies on a HubSpot developer instance to build a custom integration. I hit a really bizarre problem with the API's error message, as noted below. I am trying to send the properties in using exactly the format described in the API documentation, but it is rejecting (with HTTP 400 Bad Request) some of the company creation fields I am trying to send (in my Developer instance), with an error, where all of the names of the invalid fields are totally blank, so it's impossible to see which fields it is rejecting and why. Since something is wrong with the error message generation itself, my own troubleshooting ability is blocked as a result. Has anybody else seen this behavior before? Note I had to modify the domain value because the forum system was crashing when it was included as an auto-detected but unwanted HTML link.
send: b'POST /companies/v2/companies?hapikey=API_KEY_HERE HTTP/1.1\r\nHost: api. hubapi . comr\nUser-Agent: python-requests/2.22.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Type: application/json\r\nContent-Length: 200\r\n\r\n'
send: b'{\n    "properties": [\n        {\n            "property": "name",\n            "value": "Target"\n        },\n        {\n            "property": "domain",\n            "value": "target . com"\n        }\n    ]\n}'
reply: 'HTTP/1.1 400 Bad Request\r\n'
2020-03-03 19:12:20,829: hubspot.py: DEBUG: https:// api . hubapi . com : 443 "POST /companies/v2/companies?hapikey=API_KEY_HERE HTTP/1.1" 400 391
{"validationResults":[{"isValid":false,"message":"Property \"\" does not exist","error":"PROPERTY_DOESNT_EXIST","name":""},{"isValid":false,"message":"Property \"\" does not exist","error":"PROPERTY_DOESNT_EXIST","name":""}],"status":"error","message":"Property values were not valid","correlationId":"...","requestId":"..."}
0 Upvotes
1 Reply 1
IsaacTakushi
HubSpot Employee

Hi, @btsp.

 

I'm sorry this post fell through the cracks.

 

You've probably resolved the issue by now, but it looks like you were sending a payload to the v2 Companies API using property and value syntax.

 

Unlike the v1 Contacts API, however, the v2 Companies API accepts property names in a name field, not a property field.

 

Here's the example in the documentation:

{
  "properties": [
    {
      "name": "name",
      "value": "A company name"
    },
    {
      "name": "description",
      "value": "A company description"
    }
  ]
}

 
The fact that these two popular APIs were inconsistent and confusing led us to develop the v3 CRM APIs, which use the same structures and syntax for all CRM objects. These APIs were recently moved to full production.

Isaac Takushi

Associate Certification Manager
0 Upvotes