Best way to handle 409 Conflict in Batch Contact Create
I was writing some code to gracefully handle a 409 Conflict when sending a batch create contact request. I originally assumed that "at least one" of the contacts in the batch must be conflicted and that if I parsed the error response, I could determine the email address causing the conflict, "remove" that item from the batch and retry the request. In this way I could "clean up" the request until it worked. What I found was that, in a batch of more than one contact where at least one was a conflict, but others were not, the "non-conflicted" item(s) DOES get created, even though the request itself returns a 409.
This led to the issue of not knowing WHICH contacts got created and which did not get created. Is there a reason that that the batch create could not return a 207 Multi-status?
This link implies that a batch update SHOULD return a 207 if only partially successful but that does not seem to apply to a 409. In fact, the behavior of that endpoint differs in that the ENTIRE request fails if there is a conflict.
So, in summary:
Batch-creating multiple contacts "partially" succeeds even when one of the contacts encounters a conflict - but returns an error.
Batch-updating multiple contacts "entirely fails" when there is one single conflict.
My struggle with the way it works now is that an error is returned, but the the request may have "worked" all except for one item. In a normal situation I would have some kind of successful response that could be logged, etc. In this case I have a 409 response and the hope that "most of" of the contacts got created.
Best way to handle 409 Conflict in Batch Contact Create
I can try to help. I found that my entire batch WAS failing. So I was batching 100 contacts at a time and if one contact had a malformed email address, it would fail my entire batch. I essentially just parsed the 409 response to find the failing contact and removed them from the batch. Resent the request and the entire batch gets created.
One thing to note, this post is about duplicate emails. I'm not entirely sure if duplicate emails vs. malformed emails behave the same way. I am using Python to remove my duplicates before I send my batches to this endpoint to create my contacts
Best way to handle 409 Conflict in Batch Contact Create
How does this not have an answer yet? It was asked in 2020 originally and it's 2023 and I am running into the same issue without being able to find an answer?
Best way to handle 409 Conflict in Batch Contact Create
Any updates here? Attempting to batch update and create contacts, and the error messages are very unhelpful to determine which contact objects have been created successfully or unsuccessfully
Best way to handle 409 Conflict in Batch Contact Create
@zaklein , there was an issue created on that repo for this, but I was informed that there is no timeline on the fix. They split up a product group so one owns the contacts object so hopefully sooner than later 🤞
Mar 18, 20215:51 AM - edited Mar 18, 20217:31 AM
Member
Best way to handle 409 Conflict in Batch Contact Create
I've just encountered this issue now and it's disheatening to find a thread from Nov 2020 with no clear solution. Seems like this should definitely be a 207 response!
I feel a bit caught out as I've coded a solution using this API and now suddenly find myself feeling like the batch endpoints aren't fit for purpose which are the main endpoints I need!
Weird how the error message I recieved has even less information in it than what @aastashov posted.
To get the email to be able to identify the offending record I need to parse the error message to get the HubSpot ID and then use that to fetch the contact details with another API request...
I've noticed this issue is not just limited to conflicts either. I'm having the same thing happen for validation errors that are returning 400 responses. Yep, I'm going to have to do the same as aastashov and disable batch requests. They're unsuable in their current state.
Best way to handle 409 Conflict in Batch Contact Create
I barely found this top because it sounds like a recommendation, not a problem. But I think that the problem is the same as mine.
When trying to update a pack of objects, if there are conflicts in one of the objects, HubSpot gives 409 instead of the expected 207.
Our integration service with HubSpot collects changes to objects and once in N time makes a batch request. And now, we see a lot of duplicate errors, because, at error 409, the service does not understand which objects HubSpot was able to update and which are not.
Status: 409 Conflict
{
"status": "error",
"message": "A contact with the email 'alexander_2@gmail.com' already exists.. Existing ID: 551",
"correlationId": "f41edb07-25bf-4340-af3c-3313d09d16f6",
"category": "CONFLICT"
}
To avoid synchronization problems, I had to disable batch requests, but this will increase the number of requests to the HubSpot API and affect the limits.
Best way to handle 409 Conflict in Batch Contact Create
Hi guys! I'm trying to use HubSpot batch API and have the next problem: when I send 3 contacts tohttps://api.hubapi.com/crm/v3/objects/contact/batch/createand if one of these contacts has a problem - HubSpot response format is like this:
{ "status": "error", "message": "Property values were not valid: ......." "correlationId": "2c2b03e3-5692-4261-b462-0bea1952e562", "category": "VALIDATION_ERROR" }