In short, I am in the process of creating / testing an application that aims to create Contacts in HubSpot CRM, using the HubSpot API, for orders from our internal billing systems.
According to your documentation:
"...
When added via imports, form submissions, or API, if a contact already exists in your account with the same email address, the new contact information will be added to the existing contact record. For example, if you import a list of contacts that includes admin@hubspot.com, and an existing contact in your HubSpot account already has the email address admin@hubspot.com, the imported information will be added to that contact record.
if the created contact has an email address existing in CRM, the existing contact in HubSpot CRM will be updated. This is what happens if I use the import function on your portal (for example importing a csv file with contacts). When I am using the HubSpot API directly, I get the following error message:
Hello @PSzatan , hi @TiphaineCuisset , this happens because you are using the "POST" method on this endpoint which is not used for updating contacts, in order to update a contact you should use the "PATCH" method on this endpoint. So when you create your contacts you should add a condition that checks the response code and if it is 409 then do another call with the "PATCH" method.
Documentation that shows the 409 error for the conflict, you can find it in this link down in the "Response details" section.
Also one advice I see a lot of people are having issues with the inconcistancy of the API versions, always look in the legacy docs, they seem to be much better documented and chances are you'll find what you need there.
If my answer was helpful please mark it as a solution.
Hello @PSzatan , hi @TiphaineCuisset , this happens because you are using the "POST" method on this endpoint which is not used for updating contacts, in order to update a contact you should use the "PATCH" method on this endpoint. So when you create your contacts you should add a condition that checks the response code and if it is 409 then do another call with the "PATCH" method.
Documentation that shows the 409 error for the conflict, you can find it in this link down in the "Response details" section.
Also one advice I see a lot of people are having issues with the inconcistancy of the API versions, always look in the legacy docs, they seem to be much better documented and chances are you'll find what you need there.
If my answer was helpful please mark it as a solution.