I’ve been trying to add a contact to HubSpot via my test portal from some .NET code on my development server using one of the two following APIs (where xxx is the API key I was assigned last week):
However, testing has resulted in the following response: The remote server returned an error: (400) Bad Request.
Thinking that perhaps the above string was JSON-format challenged, I tested it at JSONLint.com where it came back as valid JSON. I therefore am finding myself at a loss for where I’m going astray and would be most appreciative of any assistance you could provide.
I am getting a similar error with some contact properties I am trying to update. The properties that fail appear to have a list of values in HS and the value I am sending in not in the list.
Is there a way to disable the value checking via the API?
I was able to garner a result using a simplified version of the code I posted earlier, substituting the APIs and changing the method to a GET. Could you please post your code for review?
In Fiddler and a browser it works perfect and I’m getting a perfectly formatted JSon in return.- But from my C# code I get a 404 error even though it’s the exact same url I’m sending via a WebRequest (GET).
Thanks for the reply. Upon stepping through the code with some fresh eyes and making some minor adjustments, I was able to garner a response from HubSpot and get my contact added. Seems the third-party online example I found for making a JSON call in .NET, while directionally accurate, was an incomplete solution.
Hi JJ,
Nothing looks immediately wrong in your JSON to me, but there are several things I can think of that might be going on. Most likely this is an encoding/serialization issue of some sort.
I’m not super familiar with .NET, but if you can log the exact request you are sending and the full response you are getting back from HubSpot, I can try to give you a better idea of what the error is.