createOrUpdate -> (400) Bad Request!


#1

Ok, suddenly my C# code didn’t work - or at least I thought so!

When calling the method createOrUpdate the following way:
serviceUrl = “https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/bbb@ccc.dd?hapikey=MyKey”;

With the following post data:
postData = “{“properties”:[{“property”:“email”,“value”:“bbb@ccc.dd”},{“property”:“firstname”,“value”:“Henrik”},{“property”:“lastname”,“value”:“JJ”}]}”;

NOTHING seemed to work except an error from Hubspot: (400) Bad Request.
Hmmm
…right method - checked!
…correct formatted JSON!

What else could be wrong?- Couldn’t find the answer untill I thought; no way Hubspot is checking for right (whatever right means) email-adress!?
Oh yes - with this little change ‘d’ to a ‘k’ in the email in the JSON everything ran smoothly again.

But why, Hubspot - why why why do you make this check in your back end (if that’s what you do) - and WHY don’t you document this in the description of the api???

Best (hrrrmpppfff) regards
Henrik


#2

Hi @HenrikJanningJuul

Our Contacts system does some basic validation on the email address before creating a contact, mostly to keep completely invalid emails out of the system. This validation won’t check to see if the email is a living, valid email account (like our embedded forms do), but it will validate the format of the address, which includes making sure that the domain ends in a valid TLD. More specific details for how that validation works can be found here:

Are you logging the body of those error responses? Those errors should have a message in the body with more details about the error, so if there was an invalid email in the request the response would have an error message saying that the email was invalid.