Occasional error associating deal with line item via Ecomm Bridge v1 API

SOLVE
New Contributor

Hello,

I am using the ecomm bridge API (v1) to sync deals and line items ('../extensions/ecomm/v1/sync-messages').  The sync request to create a deal is sent first, immediately followed by a sync request to create the line item(s).  Occasionally an error occurs for the line item sync stating that the associated deal doesn't exist (example below). 

The 'lastProcessedAt' timestamp for the deal sync request is earlier than the line item sync request, but the 'changeOccurredTimestamp' and 'errorTimestamp' for the error are before either.  Is it possible that requests will not be run (and/or not completed) in the order they are received?  Should I be checking the status of the deal sync to make sure it is complete before sending a line item sync request?

sync status of deal:
{'lastProcessedAt': 1559832530376, 'numErrors': 0, 'hubspotId': 812726231, 'objectType': 'DEAL', 'externalObjectId': '95'}

sync status of line item:
{'lastProcessedAt': 1559832530397, 'numErrors': 1, 'hubspotId': None, 'objectType': 'LINE_ITEM', 'externalObjectId': '95'}

error:
{'portalId': 5890463, 'objectType': 'LINE_ITEM', 'integratorObjectId': '95', 'changeOccurredTimestamp': 1559832528910, 'errorTimestamp': 1559832529774, 'type': 'INVALID_ASSOCIATION_PROPERTY', 'details': 'Invalid associations [hs_assoc__deal_id: 95]. Do those objects exist?', 'status': 'OPEN'}




1 Accepted solution

Accepted Solutions
Solution
HubSpot Moderator

Hey @mattbert ,

 

You're correct, the Ecommerce Bridge API processes sync messages anyncronously, so there's no guarantee that the messages will be processed in the order they're recieved. In many cases, it works fine, but if you're sending dependent messages near-simultaneously, then it's not uncommon to run into this.

 

To address your question, it's certainly possible to check the sync status of the deal object & make sure it's been created before sending the sync message for the line item. Another common design pattern is to send sync messages without validation, and frequently poll for sync errors and retry requests with invalid associations.

View solution in original post

1 Reply 1
Solution
HubSpot Moderator

Hey @mattbert ,

 

You're correct, the Ecommerce Bridge API processes sync messages anyncronously, so there's no guarantee that the messages will be processed in the order they're recieved. In many cases, it works fine, but if you're sending dependent messages near-simultaneously, then it's not uncommon to run into this.

 

To address your question, it's certainly possible to check the sync status of the deal object & make sure it's been created before sending the sync message for the line item. Another common design pattern is to send sync messages without validation, and frequently poll for sync errors and retry requests with invalid associations.

View solution in original post