API POST: "HTTP/1.1 400 Bad Request"
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Good Morning
I am new to APIs but have managed to use GET requests to pull all my contacts from Hubspot.
I am now looking to start using POST requests. I am very unexperienced with APIs and json files so I have no idea if I am doing something simple wrong. I have looked through other posts but their solutions haven't worked for me.
It is setup as follows:
 
The API key is setup as according to the endpoints in the Hubspot documentation:
https://api.hubapi.com/crm/v3/objects/companies?hapikey=...
I get the error message
HTTP/1.1 400 Bad Request
Any help would be much appreciated.
Solved! Go to Solution.
- Labels:
- API
- Developer Tools
- Error Message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hey @Matteop9
Maybe this helps you? https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Use-an-HTTP-POST-call-to-this-endpoint...
Also would encourage reaching out to @Kanderson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks for the link but it appears to address issues with the json format which I don't think I am having.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @Matteop9
I think the Json contents is not correct.
This is curl sample.
https://developers.hubspot.com/docs/api/crm/properties
curl --request POST \
--url 'https://api.hubapi.com/crm/v3/properties/objectType?hapikey=YOUR_HUBSPOT_API_KEY' \
--header 'content-type: application/json' \
--data '{
"groupName": "contactinformation",
"hidden": false,
"displayOrder": 2,
"options": [
{
"label": "Option A",
"description": "Choice number one",
"value": "A",
"displayOrder": 1,
"hidden": false
},
{
"label": "Option B",
"description": "Choice number two",
"value": "B",
"displayOrder": 2,
"hidden": false
}
],
"label": "My Contact Property",
"hasUniqueValue": false,
"type": "enumeration",
"fieldType": "select",
"formField": true
}'
Download tool send the "data part" at Payload.
At this sample, it is the red part of below.
==
--data '{
"groupName": "contactinformation",
"hidden": false,
"displayOrder": 2,
"options": [
...
"formField": true
}'
===
This endpoint url is "https://api.hubapi.com/crm/v3/properties/objectType?hapikey=YOUR_HUBSPOT_API_KEY".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
To anyone looking at the issue in the future, the name in the header "content-type" is case sensitive so needs to be "Content-Type".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Matteop9 Thanks so much man you saved the day. I knew I had everything correct but kept getting a bad request, I was giving up. I didn't know it would be a very small almost hidden detail like this causing the error, but it is always a stupid comma or space casing the syntax errors. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Matteop9 Absolute life saver, been staring at this for 2 hours wondering why it wasnt working!!
