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.
Similar to the Contacts endpoint, you cannot use the "hs_object_id" as "idProperty" because the API would try to create a value for that property, but hs_object_id can only be generated by the system when a record is created.
However, as far as I understand, it looks like there currently aren't any unique properties for the Company record. The "name" and "domain" properties are allowed to be duplicate values among records and cannot serve as the idProperty for the upsert.
What I could suggest in your case is to create a Custom Property for the Company object, make sure you mark it to require unique values. Once you have that, you could create a workflow to copy the value of the object ID to your new custom property. Then use your custom property as the "idProperty" in the upsert endpoint.
One limitation of this approach is that you will need to have that value populated for all the company records you will try to import. This means that the values in your custom property will not be a one-to-one match to the object ID in the long run.
Hope this helps!
✔️ 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
Hi @evaldas, I'm facing a similar issue with the companies batch update endpoint. I still get 'Unable to perform update/upsert by non-unique 0-2 property hs_object_id'. [info] https://api.hubapi.com/crm/v3/objects/companies/batch/update {'inputs': [{'idProperty': 'hs_object_id', 'id': '30752845452', 'properties': {...}}]} Do you have any guidance?
Similar to the Contacts endpoint, you cannot use the "hs_object_id" as "idProperty" because the API would try to create a value for that property, but hs_object_id can only be generated by the system when a record is created.
However, as far as I understand, it looks like there currently aren't any unique properties for the Company record. The "name" and "domain" properties are allowed to be duplicate values among records and cannot serve as the idProperty for the upsert.
What I could suggest in your case is to create a Custom Property for the Company object, make sure you mark it to require unique values. Once you have that, you could create a workflow to copy the value of the object ID to your new custom property. Then use your custom property as the "idProperty" in the upsert endpoint.
One limitation of this approach is that you will need to have that value populated for all the company records you will try to import. This means that the values in your custom property will not be a one-to-one match to the object ID in the long run.
Hope this helps!
✔️ 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.