Getting 400 response when sending a post request to contacts/v1/contact/vid/:vid/profile


#1

When sending the following post request, I receive a response 400. Why?

    r = requests.post("https://api.hubapi.com/contacts/v1/contact/vid/1851/profile",
                  headers={'Content-Type' : content_type,
                           'Authorization' : 'Bearer '+str(HubSpot_access_token)},
                  data={
                          "properties": [
                            {
                              "property": "email",
                              "value": "new-email@hubspot.com"
                            },
                            {
                              "property": "firstname",
                              "value": "Updated"
                            },
                            {
                              "property": "lastname",
                              "value": "Record"
                            },
                            {
                              "property": "website",
                              "value": "http://updated.example.com"
                            }
                          ]
                        })


#2

Hi @RespaunceMartin,

Looking in your app's logs, I see that the POST request on Sept 4, 2018 9:46:50 AM EDT had its body formatted in application/x-www-form-urlencoded:

properties=property&properties=value&properties=property&properties=value&properties=property&properties=value&properties=property&properties=value

...rather than the JSON copied above and recommended in the developer documentation. See below:

I was able to replicate the same error in my own account using your request body:

If the payload is properly-formatted JSON, per this example, you should receive a 204 No Content response.


#4