APIs & Integrations

eibach-cv
Contributor

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

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") + """\"
                        ]
                    }   
                }
            ]
        }

 

0 Upvotes
1 Accepted solution
himanshurauthan
Solution
Thought Leader | Elite Partner
Thought Leader | Elite Partner

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

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 - https://legacydocs.hubspot.com/docs/methods/ecommerce/v2/check-sync-status

I Hope, this will fix your issue.

 

Thanks,
Himanshu

Digital Marketing & Inbound Expert In Growth Hacking Technology

View solution in original post

14 Replies 14
himanshurauthan
Thought Leader | Elite Partner
Thought Leader | Elite Partner

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

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 - https://legacydocs.hubspot.com/docs/methods/ecommerce/v2/send-sync-messages
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 ) https://legacydocs.hubspot.com/docs/methods/ecommerce/v2/send-sync-messages

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 

Digital Marketing & Inbound Expert In Growth Hacking Technology
eibach-cv
Contributor

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

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"
                        ]
                    }
                }
            ]
        }

 

0 Upvotes
himanshurauthan
Solution
Thought Leader | Elite Partner
Thought Leader | Elite Partner

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

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 - https://legacydocs.hubspot.com/docs/methods/ecommerce/v2/check-sync-status

I Hope, this will fix your issue.

 

Thanks,
Himanshu

Digital Marketing & Inbound Expert In Growth Hacking Technology
Mike_Eastwood
Key Advisor | Gold Partner
Key Advisor | Gold Partner

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

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

dennisedson
HubSpot Product Team
HubSpot Product Team

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

@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

0 Upvotes
btsp
Contributor

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

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.

eibach-cv
Contributor

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

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?

0 Upvotes
btsp
Contributor

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

@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 .

eibach-cv
Contributor

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

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
        }
    ]
}
0 Upvotes
eibach-cv
Contributor

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

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:

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?

0 Upvotes
btsp
Contributor

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE


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.

0 Upvotes
eibach-cv
Contributor

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

@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

Screenshot_15.pngScreenshot_16.png

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

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

 

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Missing required fields [hs_assoc__product_id] error on line item sync

SOLVE

Hey @eibach-cv ,

Sorry that you are still struggling with this..

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

0 Upvotes