APIs & Integrations

lrolf
Member

400 Error Custom Contacts Field

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.

I’m able to successfully run the script using:
https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/testingapis@hubspot.com/?hapikey=xxx...
PostData = “{”“properties””: [{"“property”": ““email””,"“value”": ""test6@quwho.com""},{"“property”": ““firstname””,"“value”": ““Linda66"”}]}”

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?

I appreciate any help. I’m stuck.

0 Upvotes
11 Replies 11
Not applicable

400 Error Custom Contacts Field

Yes, i found the solution myself.

My issue is i am using "hapiKey=Demo" as query string in http request instead of original API key.

I did not no that demo will not work on custom fields.

0 Upvotes
lrolf
Member

400 Error Custom Contacts Field

Great, glad you were able to solve your problem. I know how frustrating it can be.

0 Upvotes
Not applicable

400 Error Custom Contacts Field

I am getting this error too.

Is this solved? Can someone let me know how to fix this?

0 Upvotes
lrolf
Member

400 Error Custom Contacts Field

Ravi,

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.

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

400 Error Custom Contacts Field

Hi @lrolf,

Can you direct message me with your hapikey and Hub ID so that I can do some testing?

0 Upvotes
lrolf
Member

400 Error Custom Contacts Field

Hi Derek,

i emailed the HAPIkey and Hub Id to you yesterday. Thanks for your help.

Derek_Gervais
HubSpot Alumni
HubSpot Alumni

400 Error Custom Contacts Field

Hi @lrolf,

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").

0 Upvotes
lrolf
Member

400 Error Custom Contacts Field

Derek,

I changed the “” to “, fixed a missing {, and ran the data through JsonLint. I’m getting a valid Json response. A 400 is still being returned.

Linda Rolf
Linda Rolf
President

Quest Technology Group | Quwho
315 E. Robinson Street, Suite 525
Orlando, FL 32801
407.843-6603
http://www.quest-technology-group.com www.quest-technology-group.com
http://www.quwho.com/ www.quwho.com

Quest Mobility Solutions
Creating Accessible Living Spaces
3915 E Colonial Drive
Orlando, FL 32803
407.898.2998
http://www.questmobilitysolutions.com/ www.questmobilitysolutions.com

http://www.linkedin.com/profile?viewProfile=&key=30305331&locale=en_US&trk=tab_pro linkedin-30 http://www.twitter.com/questtechgroup twitter-30

0 Upvotes
lrolf
Member

400 Error Custom Contacts Field

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.

Linda Rolf
Linda Rolf
President

Quest Technology Group | Quwho
315 E. Robinson Street, Suite 525
Orlando, FL 32801
407.843-6603
http://www.quest-technology-group.com www.quest-technology-group.com
http://www.quwho.com/ www.quwho.com

Quest Mobility Solutions
Creating Accessible Living Spaces
3915 E Colonial Drive
Orlando, FL 32803
407.898.2998
http://www.questmobilitysolutions.com/ www.questmobilitysolutions.com

http://www.linkedin.com/profile?viewProfile=&key=30305331&locale=en_US&trk=tab_pro linkedin-30 http://www.twitter.com/questtechgroup twitter-30

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

400 Error Custom Contacts Field

Hi @lrolf,

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.

0 Upvotes
lrolf
Member

400 Error Custom Contacts Field

Derek,

Thanks for pointing me to the date property. I’ve converted them to Unix format, but I’m still getting a 400 error. There is no other response.

Here are the first and last records in the input –

data = [{ “” email “” : ""AJAY.KAILAS91@FOO.COM"" ,"“properties”":[ {"“property”": “” firstname “”, ““value””: " “AJAY”" }, {"“property”": “” lastname “”, ““value””: ““KAILAS”” }, {"“property”": “” birth_date “”, ““value””: “1534118400000” }, {"“property”": “” course_enroll_date “”, ““value””: “1475798400000” }, {"“property”": “” course_completed_date “”, ““value””: “1478390400000” }] “” email “” : ""LIANALOVEBUG@GMAIL.COM"" ,"“properties”":[ {"“property”": “” firstname “”, ““value””: " “LIANA”" }, {"“property”": “” lastname “”, ““value””: ““RIVERA”” }, {"“property”": “” birth_date “”, ““value””: “1481673600000” }, {"“property”": “” course_enroll_date “”, ““value””: “1475798400000” }, {"“property”": “” course_completed_date “”, ““value””: “1478390400000” }]}]

400

Linda Rolf
Linda Rolf
President

Quest Technology Group | Quwho
315 E. Robinson Street, Suite 525
Orlando, FL 32801
407.843-6603
http://www.quest-technology-group.com www.quest-technology-group.com
http://www.quwho.com/ www.quwho.com

Quest Mobility Solutions
Creating Accessible Living Spaces
3915 E Colonial Drive
Orlando, FL 32803
407.898.2998
http://www.questmobilitysolutions.com/ www.questmobilitysolutions.com

http://www.linkedin.com/profile?viewProfile=&key=30305331&locale=en_US&trk=tab_pro linkedin-30 http://www.twitter.com/questtechgroup twitter-30

0 Upvotes