Missing required fields [hs_assoc__product_id] error on line item sync

I posted this 3 weeks ago and never got an answer, so trying again with a new post…

I’m tyring to send a LINE_ITEM sync request, but I’m getting an error that I need to include the hs_asssoc__product_id field.

{
 "storeId": "eib-wsm",
 "objectType": "LINE_ITEM",
 "externalObjectId": "63979",
 "hubspotId": null,
 "lastProcessedAt": 1604959697554,
 "errors": [
 {
 "portalId": 8172849,
 "storeId": "eib-wsm",
 "objectType": "LINE_ITEM",
 "externalObjectId": "63979",
 "changedAt": 1604959696759,
 "erroredAt": 1604959697112,
 "type": "MISSING_REQUIRED_PROPERTY",
 "details": "Message missing required fields [hs_assoc__product_id]",
 "status": "OPEN"
 }
 ]
}

How would I get this data and include it in my request if its an id generated by HubSpot?

{
 "storeId": "eib-wsm", 
 "objectType": "LINE_ITEM", 
 "messages": [ 
 { 
 "action": "UPSERT", 
 "externalObjectId": \"""" + item.get("ItemID") + """\", 
 "properties": { 
 "quantity": \"""" + item.get("Quantity") + """\",
 "price": \"""" + item.get("UnitPrice") + """\",
 "name": \"""" + item.get("DealerCode") + """\",
 "hs_assoc__product_id": "??????"
 }, 
 "associations": {
 "DEAL": [
 \"""" + order["Id"] + """\"
 ],
 "PRODUCT": [
 \"""" + item.get("ProductID") + """\"
 ]
 } 
 }
 ]
 }

Hey @eibach-cv ,

Sorry that you are still struggling with this..

@Mike_Eastwood , @btsp, do you all have familiarity with the Ecommerce Bridge?

This is somewhat difficult to follow because it is not including the endpoint path that was used. Looking at the post tags it would appear it is in the e-commerce bridge which only a few people are using, and I don’t use it because I am selling services not goods.

Designing it in my head blind with no testing, I THINK you will get the ID you need by using the data from /crm/v3/objects/line_items/{lineItemId}/associations/{toObjectType} and /crm/v3/objects/products/{productId} though. Put the line item into the first API by its ID and object type product. Then you can see the product ID directly, and the details of the product if needed via the second API using the ID discovered using the first.

One of my favorite things to watch is @btsp design things blindly in his head

Sorry, this might be easier to follow with the values put in instead of variables.

And yes this is ecommerce bridge which I was told by Hubspot to use (a little concerning to hear that only a few people use it)

{
 "storeId": "eib-wsm",
 "objectType": "LINE_ITEM",
 "messages": [
 {
 "action": "UPSERT",
 "externalObjectId": "63979",
 "properties": {
 "quantity": "2",
 "price": "28.00",
 "name": "5.81290K",
 "hs_product_id": "????????"
 },
 "associations": {
 "DEAL": [
 "831718"
 ]
 }
 }
 ]
 }

@btsp wrote:

I THINK you will get the ID you need by using the data … /crm/v3/objects/products/{productId}


I need the productId to get the hs_product_id? Aren’t those the same thing? How do I get it if I don’t know it to begin with?



I need the productId to get the hs_product_id? Aren’t those the same thing? How do I get it if I don’t know it to begin with?


You did not read the entire reply fully. I also included /crm/v3/objects/line_items/{lineItemId}/associations/{toObjectType} and explained that you need that one for just IDs, and this other one to get any further properties or details.


@btsp wrote:



I need the productId to get the hs_product_id? Aren’t those the same thing? How do I get it if I don’t know it to begin with?


You did not read the entire reply fully. I also included /crm/v3/objects/line_items/{lineItemId}/associations/{toObjectType} and explained that you need that one for just IDs, and this other one to get any further properties or details.


I read the part about running /crm/v3/objects/line_items/{lineItemId}/associations/{toObjectType}, but that doesn’t return anything because the error I showed prevents any associations from being made.

I made some changes to my call and got a slightly different error. Changes and error are below:

CODE - change being adding the product association

{
 "storeId": "eib-wsm",
 "objectType": "LINE_ITEM",
 "messages": [
 {
 "action": "UPSERT",
 "externalObjectId": "63979",
 "properties": {
 "quantity": "2",
 "price": "28.00",
 "name": "5.81290K"
 },
 "associations": {
 "DEAL": [
 "831718"
 ],
 "PRODUCT": [
 "10482"
 ]
 }
 }
 ]
 }

ERROR

{
 "storeId": "eib-wsm",
 "objectType": "LINE_ITEM",
 "externalObjectId": "63979",
 "hubspotId": null,
 "lastProcessedAt": 1607441289586,
 "errors": [
 {
 "portalId": 8172849,
 "storeId": "eib-wsm",
 "objectType": "LINE_ITEM",
 "externalObjectId": "63979",
 "changedAt": 1607441288897,
 "erroredAt": 1607441298904,
 "type": "INVALID_ASSOCIATION_PROPERTY",
 "details": "Invalid associations [hs_assoc__product_id: eib-wsm__10482]. Do those objects exist?",
 "status": "OPEN"
 }
 ]
}

The documentation example on Hubspot shows to use the product externalobjectid in the line item associations which I have done. It does not show/mention anything about hs_assoc__product_id

Is there no way for me to retrieve the hs_assoc__product_id by using our product SKU or external object iD to look it up?


@eibach-cv wrote:

Is there no way for me to retrieve the hs_assoc__product_id by using our product SKU or external object iD to look it up?


Of course you can do this; /crm/v3/objects/products/search .

I got the search working and returned a product. The only id I see is the hs_object_id which does not match the format in the error message of eib-wsm-xxxxxxxxxx

"details": "Invalid associations [hs_assoc__product_id: eib-wsm__10482]. Do those objects exist?",

{
 "total": 1,
 "results": [
 {
 "id": "414744818",
 "properties": {
 "createdate": "2020-12-07T23:04:47.812Z",
 "description": "EIBACH COILOVER SPRING",
 "hs_lastmodifieddate": "2020-12-10T15:46:34.601Z",
 "hs_object_id": "414744818",
 "name": "0900.225.0500",
 "price": "70.00"
 },
 "createdAt": "2020-12-07T23:04:47.812Z",
 "updatedAt": "2020-12-10T15:46:34.601Z",
 "archived": false
 }
 ]
}

@himanshurauthan is the resident expert with Ecommerce Bridge. Hoping he can add his voice. @Mike_Eastwood , I forget if you have experience with it is as well

Sorry, I’m just watching @btsp and nodding (not knowing myself).

Hello @eibach-cv

Can you please share all the steps you followed for creating a LINE_ITEM?

Here are the minimum steps that you have to follow -

1- upsert ecomm settings - Accounts Dashboard | HubSpot
2- Send sync message ( in your case you have send PRODCT sync message, and in the message you have to send externalObjectId that you can use any unique identifier from your product source ) Accounts Dashboard | HubSpot

And now you can send the LINE_ITEM sync message, with the unique identifier that you have provided in the previous step as a hs_asssoc__product_id
Thanks,
Himanshu

Hi @Hima

I ran the upsert with the following code

{
 "enabled": true,
 "webhookUri": null,
 "mappings": {
 "CONTACT": {
 "properties": [
 {
 "externalPropertyName": "email",
 "hubspotPropertyName": "email",
 "dataType": "STRING"
 },
 {
 "externalPropertyName": "firstname",
 "hubspotPropertyName": "firstname",
 "dataType": "STRING"
 },
 {
 "externalPropertyName": "lastname",
 "hubspotPropertyName": "lastname",
 "dataType": "STRING"
 },
 {
 "externalPropertyName": "phone",
 "hubspotPropertyName": "mobilephone",
 "dataType": "STRING"
 }
 ]
 },
 "DEAL": {
 "properties": [
 {
 "externalPropertyName": "dealstage",
 "hubspotPropertyName": "dealstage",
 "dataType": "STRING"
 },
 {
 "externalPropertyName": "amount",
 "hubspotPropertyName": "amount",
 "dataType": "NUMBER"
 },
 {
 "externalPropertyName": "dealname",
 "hubspotPropertyName": "dealname",
 "dataType": "STRING"
 },
 {
 "externalPropertyName": "order_number",
 "hubspotPropertyName": "ip__ecomm_bridge__order_number",
 "dataType": "STRING"
 },
 {
 "externalPropertyName": "tax",
 "hubspotPropertyName": "ip__ecomm_bridge__tax_amount",
 "dataType": "NUMBER"
 },
 {
 "externalPropertyName": "closedate",
 "hubspotPropertyName": "closedate",
 "dataType": "DATETIME"
 },
 {
 "externalPropertyName": "createdate",
 "hubspotPropertyName": "createdate",
 "dataType": "DATETIME"
 }
 ]
 },
 "PRODUCT": {
 "properties": [
 {
 "externalPropertyName": "price",
 "hubspotPropertyName": "price",
 "dataType": "NUMBER"
 },
 {
 "externalPropertyName": "description",
 "hubspotPropertyName": "description",
 "dataType": "STRING"
 },
 {
 "externalPropertyName": "name",
 "hubspotPropertyName": "name",
 "dataType": "STRING"
 },
 {
 "externalPropertyName": "sku",
 "hubspotPropertyName": "hs_sku",
 "dataType": "STRING"
 }
 ]
 },
 "LINE_ITEM": {
 "properties": [
 {
 "externalPropertyName": "quantity",
 "hubspotPropertyName": "quantity",
 "dataType": "NUMBER"
 },
 {
 "externalPropertyName": "price",
 "hubspotPropertyName": "price",
 "dataType": "NUMBER"
 },
 {
 "externalPropertyName": "name",
 "hubspotPropertyName": "name",
 "dataType": "STRING"
 },
 {
 "externalPropertyName": "hs_product_id",
 "hubspotPropertyName": "hs_product_id",
 "dataType": "NUMBER"
 }
 ]
 }
 }
}

Then I sent all PRODUCT messages like this specific example:

{
 "storeId": "eib-wsm",
 "objectType": "PRODUCT",
 "messages": [
 {
 "action": "UPSERT",
 "externalObjectId": "10482",
 "properties": {
 "price": "28.00",
 "description": "PRO-ALIGNMENT Camber Bolt Kit",
 "name": "5.81290K",
 "sku": "5.81290K|2109"
 },
 "associations": {

 }
 }
 ]
 }

Then I sent my LINE_ITEM message like this:

{
 "storeId": "eib-wsm",
 "objectType": "LINE_ITEM",
 "messages": [
 {
 "action": "UPSERT",
 "externalObjectId": "63979",
 "properties": {
 "quantity": "2",
 "price": "28.00",
 "name": "5.81290K",
 "hs_assoc__deal_id": "831718",
 "hs_assoc__product_id": "10482", },
 "associations": {
 "DEAL": [
 "831718"
 ],
 "PRODUCT": [
 "10482"
 ]
 }
 }
 ]
 }

Hi @eibach-cv,

You are doing it all right, but can you please check the status of your sync and make the upsert call when your dependent association objects sync is successfully synced.

Here is how you can check the sync status - Accounts Dashboard | HubSpot

I Hope, this will fix your issue.

Thanks,
Himanshu