I’m testing my API code updating contacts from an external application. We have 3 custom fields that have been added to HubSpot. When I include these custom fields in the JSON data, I’m getting a 400 error.
This data returns a 400:
PostData = “{”“properties”": [{"“property”": ““email””,"“value”": ""test6@quwho.com""},{"“property”": ““firstname””,"“value”": ““Linda66"”},{”“property”":"“birth_date”","“value”":"“11021966"”}]}"
i even changed the firstname and value in the successful data to the birth_date property and value. It returned a 400.
All of the custom fields are dates. Is there something I’m not doing correctly?
Have you run your json file through a validator like jsonlint to ensure there are no syntax errors?
My problem was resolved when I used a test portal instead of the developer portal. I suppose it should have been obvious to me, but I wrongly assumed developer meant developer.
It looks like each key/value is wrapped in two sets of double quotes (i.e. ““email”” : ""AJAY.KAILAS91@FOO.COM""). Is this a formatting error, or are the keys/values wrapped like this in the request? Proper JSON should have each key/value wrapped in a single set of double quotes (i.e. “email” : "AJAY.KAILAS91@FOO.COM").
This is based on working code that I successfully tested. A single contact update worked with the double quotes. Now that I’ve added the custom date fields, I’m getting the 400 error. We’re using ServerXmlHttp with ASP.
I can try replacing the double quotes with single and see if that works.
HubSpot date properties are unix timestamps in milliseconds; it looks like the value in your example is in seconds. Can you try making the request again, but with the timestamp formatted in milliseconds? If that doesn’t resolve the issue, can you respond withe the full error response body? That will give me a better idea where the issue may lie.