Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

API POST: "HTTP/1.1 400 Bad Request"

Matteop9
8 - Asteroid

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:

Untitled.png

 

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.

6 REPLIES 6
joshuaburkhow
ACE Emeritus
ACE Emeritus

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 

Joshua Burkhow - Alteryx Ace | Global Alteryx Architect @PwC | Blogger @ AlterTricks
Matteop9
8 - Asteroid

Thanks for the link but it appears to address issues with the json format which I don't think I am having.

AkimasaKajitani
17 - Castor
17 - Castor

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

Matteop9
8 - Asteroid

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

aalayid7
5 - Atom

@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!

will___________
5 - Atom

@Matteop9 Absolute life saver, been staring at this for 2 hours wondering why it wasnt working!!

Labels