Issue creating Contact Property via API


#1

We are trying to create a custom Contact property via the API, but all our POST requests return a Bad Request 400.

The body of the response is HTML and contains the following;

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
  <title>Error 400 Bad Request</title>
</head>
<body>
  <h2>HTTP ERROR 400</h2>
  <p>Problem accessing /properties/v2/contact/properties. Reason:
    <pre>    Bad Request</pre>
  </p>
</body>
</html>

Here is the request body we are trying to send, which is actually from the API documentation

{
  "name":         "newcustomproperty",
  "label":        "A New Custom Property",
  "description":  "A new property for you",
  "groupName":    "contactinformation",
  "type":         "string",
  "fieldType":    "text",
  "formField":    true,
  "displayOrder": 6,
  "options":      []
}

Not sure what to check from here. The only thing I noted was that the response from the API refers to a "v2" API url, so wondering if the request format has changed somehow?

Thanks!


#2

Hi @Liam,

How are you making this request? When I copy and paste the example from the Developer Docs into Postman to test this, with a method of POST to this URL
https://api.hubapi.com/properties/v1/contacts/properties?hapikey=my_hapikey_here
I get a 200 success message and the property is created. Make sure you also have the Content-Type set to application/json as a header.

As per the docs:

Returns a 400 error with more details in the response body if there is any other 
problem with the data.

I think the v2 error listed is a red herring, as I tried submitting a POST request without the content type set to application/json, and got a 415 Unsupported Media type error very similarly formatted to the error you have above.