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
Bumping this in 2024. Did anyone find a solution? I just want to be able to send the hubspot api some contacts and have it skip ones with email addresses that already exist. The thought crossed my mind to export to csv and then use the file upload endpoint but that seems like extra work for a feature that should happen by default
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 🤞
HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates. Learn More.
Best way to handle 409 Conflict in Batch Contact Create
I put the question back out there to the team 🤞
HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates. Learn More.
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.