APIs & Integrations

i_am_sahil
Member

Create or update a batch of contacts by unique property values API error

SOLVE

I'm using the Create or update a batch of contacts by unique property values endpoint to batch upsert contact records.

 

Here's what my request looks like. When I'm using the HubSpot ID of the record, I get a 400 Bad Request error. However, when I keep everything same and replace the HubSpot ID with a custom unique property that I created, it works like a charm!

 

The question is, how do I make it work using HubSpot's record ID as they're also unique?

 

Request

{
"inputs": [
{
"idProperty": "hs_object_id",
"id": 42068156885,
"properties": {
"firstname": "TEST",
"lastname": "Record",
"email": "testrecord@gmail.com",
"phone": "+321234567",
"address": "Nantes, Pays de la Loire, France",
"city": "Nantes",
"jobtitle": "Director",
"hs_linkedin_url": "https://www.linkedin.com/in/test",
"salutation": "Mr",
"stage_rcrm": "prospect",
"updated_at": "2024-09-30"
}
}
]
}
 
Response
{
"status": "error",
"message": "Unable to perform update/upsert by non-unique 0-1 property hs_object_id in portal ID 145356037",
"correlationId": "849976e2-8660-4214-91cf-2967fe8322a2",
"category": "VALIDATION_ERROR"
}
 
[PS: I have masked all personal information for obvious reasons.]
0 Upvotes
1 Accepted solution
evaldas
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

Create or update a batch of contacts by unique property values API error

SOLVE

Hey @i_am_sahil,

 

Apparently there was a mistake in the doc and actually you cannot use "hs_object_id" in the upsert endpoint. This is because this endpoint would create a contact if the id does not match, but the "hs_object_id" cannot be modified nor created via APIs. Therefore, the record id can only be used for the batch update endpoint. The docs will be updated accordingly.

 

That being said, you can use either the email property or a custom property (with a unique value) for the upsert endpoint. 

 


✔️ Did this post help answer your query? Help the community by marking it as a solution.

View solution in original post

0 Upvotes
3 Replies 3
evaldas
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

Create or update a batch of contacts by unique property values API error

SOLVE

Hi @i_am_sahil,

 

Have you tried leaving out the "idProperty": "hs_object_id" line? 

 

According to to the CRM API documentation, "idProperty" is only required when you are using something other than the "hs_object_id":

 

By default, the id values in the request refer to the record ID (hs_object_id), so the idProperty parameter is not required when retrieving by record ID. If you're using email or a custom unique value property to retrieve contacts, you must include the idProperty parameter.

 

 


✔️ Did this post help answer your query? Help the community by marking it as a solution.

0 Upvotes
i_am_sahil
Member

Create or update a batch of contacts by unique property values API error

SOLVE

Hey @evaldas - I tried leaving out the "idProperty": "hs_object_id" line, and it still doesn't work 😞

 

HubSpot's documentation clearly states id can be used!

 

i_am_sahil_0-1727719792452.png

Here's the error

{
"status": "error",
"message": "Updates in a single batch must specify its unique property.",
"correlationId": "4b5ded01-a49c-4de1-bc39-a45ca38d4463",
"category": "VALIDATION_ERROR"
}
0 Upvotes
evaldas
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

Create or update a batch of contacts by unique property values API error

SOLVE

Hey @i_am_sahil,

 

Apparently there was a mistake in the doc and actually you cannot use "hs_object_id" in the upsert endpoint. This is because this endpoint would create a contact if the id does not match, but the "hs_object_id" cannot be modified nor created via APIs. Therefore, the record id can only be used for the batch update endpoint. The docs will be updated accordingly.

 

That being said, you can use either the email property or a custom property (with a unique value) for the upsert endpoint. 

 


✔️ Did this post help answer your query? Help the community by marking it as a solution.

0 Upvotes