APIs & Integrations

SLotti
Member

How to handle, status of PENDING on contact upsert

SOLVE

Hi,

 

I see in the docs it show status="PENDING" as a possible response, so far I've only seen "COMPLETE".

I don't know how to handle the pending result, is there a batch key and a way to query the batch?

For my processing I need to get the contact ID from the result and that is returned in the results[].id but I don't know if its there for PENDING.  

Thank you

-Sam

 

0 Upvotes
1 Accepted solution
nickdeckerdevs1
Solution
Contributor | Platinum Partner
Contributor | Platinum Partner

How to handle, status of PENDING on contact upsert

SOLVE

I've never seen pending, doesn't mean it doesn't get returned though. I see the examples showing it in there.

So if I were trying to figure this out, I would get the results I do have, sending in an objectWriteTraceId, and then I see all the records that are created (matching on the email address)

Any of the ones you don't have complete, you could extend your promise, add a delay, whatever you need to do in your code, then get the contacts by their email address and see if they are created, returning the IDs from that. 

Does this make sense? Use the data you are sending, or generate an array of objects like 
[{"email": "email1@domain.com", "hs_object_id": "1234"},...] from the data you do have IDs for, and then delay your code, find the ones that you don't have IDs for look them up after a delay, and do that recursivly until you have all of them set up.

note:
objectWriteTraceId is a property you can set when creating these batches. Some people use and store this unique string by using some sort of naming convention like from-domain-2025-2-14-020220 -- using date and time properties to generate that trace id
https://developers.hubspot.com/docs/reference/api/other-resources/error-handling#multi-status-errors



View solution in original post

0 Upvotes
1 Reply 1
nickdeckerdevs1
Solution
Contributor | Platinum Partner
Contributor | Platinum Partner

How to handle, status of PENDING on contact upsert

SOLVE

I've never seen pending, doesn't mean it doesn't get returned though. I see the examples showing it in there.

So if I were trying to figure this out, I would get the results I do have, sending in an objectWriteTraceId, and then I see all the records that are created (matching on the email address)

Any of the ones you don't have complete, you could extend your promise, add a delay, whatever you need to do in your code, then get the contacts by their email address and see if they are created, returning the IDs from that. 

Does this make sense? Use the data you are sending, or generate an array of objects like 
[{"email": "email1@domain.com", "hs_object_id": "1234"},...] from the data you do have IDs for, and then delay your code, find the ones that you don't have IDs for look them up after a delay, and do that recursivly until you have all of them set up.

note:
objectWriteTraceId is a property you can set when creating these batches. Some people use and store this unique string by using some sort of naming convention like from-domain-2025-2-14-020220 -- using date and time properties to generate that trace id
https://developers.hubspot.com/docs/reference/api/other-resources/error-handling#multi-status-errors



0 Upvotes