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.]
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.
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.
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!
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" }
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.