APIs & Integrations

Nizar2
Participant

API: Simple custom Object POST not working

SOLVE

Hi everyone!

 

So, I have a custom record with 4 properties. I want to create a new record of this object.

 

i do POST to api.hubapi.com/crm/v4/objects/2-41795069

 

the body is as follow:

{
"properties":
[
{
"name": "external_id",
"color": "EQ",
"size": "X1010"
}
]
}

The API returns a list of records rather than creating a new one.

 

Nizar2_0-1742173033639.png

I dont know what I am doing wrong here.

 

 

0 Upvotes
1 Accepted solution
MichaelMa
Solution
Contributor

API: Simple custom Object POST not working

SOLVE

Please try writing out the entire url with the https in front (whichever API version works for you):

https://api.hubapi.com/crm/v4/objects/2-41795069

https://api.hubapi.com/crm/v3/objects/2-41795069

 

I'm guessing that Postman is posting to the http URL and in your Postman settings, you do NOT have the option enabled to "Follow original HTTP method" to continue using POST when it gets redirected to the https url.

 

So when it does get redirected from http -> https, it switches to GET which is why you're always getting the results.

View solution in original post

6 Replies 6
MichaelMa
Solution
Contributor

API: Simple custom Object POST not working

SOLVE

Please try writing out the entire url with the https in front (whichever API version works for you):

https://api.hubapi.com/crm/v4/objects/2-41795069

https://api.hubapi.com/crm/v3/objects/2-41795069

 

I'm guessing that Postman is posting to the http URL and in your Postman settings, you do NOT have the option enabled to "Follow original HTTP method" to continue using POST when it gets redirected to the https url.

 

So when it does get redirected from http -> https, it switches to GET which is why you're always getting the results.

Nizar2
Participant

API: Simple custom Object POST not working

SOLVE

Somehow I overlooked your respone. Adding the HTTPS at the begginning fixed it. You're the best!

GiantFocal
Top Contributor | Gold Partner
Top Contributor | Gold Partner

API: Simple custom Object POST not working

SOLVE

Hi @Nizar2,

 

Your JSON request body structure is incorrect. When creating custom objects, HubSpot's API requires a key-value pair object, not an array, for the properties field.

 

Here's how your request should be formatted:

{
  "properties": {
    "external_id": "your_value_here",
    "color": "EQ",
    "size": "X1010"
  }
}

 

Best regards,
Ernesto @ GiantFocal
Found this answer helpful?
Marking it as the solution helps both the community and me - thanks in advance!
Nizar2
Participant

API: Simple custom Object POST not working

SOLVE

Hey @GiantFocal ,

 

Thanks for your reply!

 

Unfortunately, that what I was trying for the past couple of days with no success. No errors. The response is always the list of the records.

 

{
"properties": {
"color": "EQ",
"size": "X1010",
"name": "Nizar"
}
}

 

Nizar2_0-1742191409362.png

 

Could be I am using the wrong URL? Or Method?

 

api.hubapi.com/crm/v4/objects/2-41795069 ?

 

Your help is highly appreciated.

 

0 Upvotes
SteveHTM
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

API: Simple custom Object POST not working

SOLVE

@Nizar2 - I see you are attempting to call a v4 API. The only version I see documented for this POST call is V3: https://api.hubapi.com/crm/v3/objects/{objectType}

 

Could that be an issue?

 

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Upvotes
Nizar2
Participant

API: Simple custom Object POST not working

SOLVE

Hey Steve!

 

Thanks for your reply!

 

I get the same result with v3.

 

Nizar2_0-1742235927936.png

 

0 Upvotes