# Line\_items are not creating every time via eCommerce Bridge API

**URL:** <https://community.hubspot.com/t/line-items-are-not-creating-every-time-via-ecommerce-bridge-api/17569>\
**Category:** APIs & Integrations\
**Tags:** object, contacts\
**Created:** [December 5, 2019, 5:20am UTC](https://community.hubspot.com/t/line-items-are-not-creating-every-time-via-ecommerce-bridge-api/17569 "2019-12-05T05:20:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahesh1250](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mahesh1250/32/97852_2.png) [@Mahesh1250](https://community.hubspot.com/u/Mahesh1250)\
**Post date:** [December 5, 2019, 5:20am UTC](https://community.hubspot.com/t/line-items-are-not-creating-every-time-via-ecommerce-bridge-api/17569/1 "2019-12-05T05:20:37Z")

</div>

Hi Experts,

While creating DEAL via eCommerce Bridge API, LINE\_ITEMS are not creating every time. sometimes it works 1 out of 5 times. Why it’s behaving this way?

Please see the process I’m following and suggest me the solution.

Step # 1: creating Contact with externalObjectID

```auto
{
 "storeId": "ecommercebridge-deviceb2b-store",
 "objectType": "CONTACT",
 "messages": [
 {
 "action": "UPSERT",
 "changedAt": 1575522058436,
 "externalObjectId": "test@test.com",
 "properties": {
 "email": "test@test.com"
 }
 }
 ]
}

```

Step #2: Creating DEAL & associate with CONTACT

```auto
{
 "storeId": "ecommercebridge-deviceb2b-store",
 "objectType": "DEAL",
 "messages": [
 {
 "action": "UPSERT",
 "changedAt": 1575522058736,
 "externalObjectId": "deal_0000735706",
 "properties": {
 "dealname": "Deal 0000735706",
 "dealstage": "processed",
 "closedate": 1575522058736,
 "amount": 18,
 "sapordernumber": "0000735706",
 "companyname": "xxxx xxx xx xxxx",
 "createdate": 1575522058736
 },
 "associations": {
 "CONTACT": [
 "test@test.com"
 ]
 }
 }
 ]
}

```

Step #3: Creating PRODUCT with externalObjectID

```auto
{
 "storeId": "ecommercebridge-deviceb2b-store",
 "objectType": "PRODUCT",
 "messages": [
 {
 "action": "UPSERT",
 "changedAt": 1575522059010,
 "externalObjectId": "xx-SM-060",
 "properties": {
 "product_name": "Koo Air Cushion Anaesthetic Masks - Size 0",
 "product_description": "xxxx"
 }
 },
 {
 "action": "UPSERT",
 "changedAt": 1575522059010,
 "externalObjectId": "xx-SM-062B",
 "properties": {
 "product_name": "xxxx"
 }
 },
 {
 "action": "UPSERT",
 "changedAt": 1575522059010,
 "externalObjectId": "xx-AM03",
 "properties": {
 "product_name": "xxxx"
 }
 }
 ]
}

```

Step #4: Creating LINE\_ITEM and associate with PRODUCT & DEAL

```auto
{
 "storeId": "ecommercebridge-deviceb2b-store",
 "objectType": "LINE_ITEM",
 "messages": [
 {
 "action": "UPSERT",
 "changedAt": 1575522059307,
 "externalObjectId": "lineItem_xx-SM-060",
 "properties": {
 "product_name": "Koo Air Cushion Anaesthetic Masks - Size 0",
 "product_description": "xxxx",
 "quantity": 1,
 "price": 3,
 "amount": 3,
 "createdate": 1575522059307
 },
 "associations": {
 "DEAL": [
 "deal_0000735706"
 ],
 "PRODUCT": [
 "xx-SM-060"
 ]
 }
 },
 {
 "action": "UPSERT",
 "changedAt": 1575522059307,
 "externalObjectId": "lineItem_xx-SM-062B",
 "properties": {
 "product_name": "Koo Air Cushion Anaesthetic Masks - Size 2 - Bubblegum",
 "product_description": "xxxx",
 "quantity": 2,
 "price": 3,
 "amount": 6,
 "createdate": 1575522059307
 },
 "associations": {
 "DEAL": [
 "deal_0000735706"
 ],
 "PRODUCT": [
 "xx-SM-062B"
 ]
 }
 },
 {
 "action": "UPSERT",
 "changedAt": 1575522059307,
 "externalObjectId": "lineItem_xx-AM03",
 "properties": {
 "product_name": "Well Lead Air Cushion Disposable Anaesthesia Mask - Size 3",
 "product_description": "xxxx",
 "quantity": 3,
 "price": 3,
 "amount": 9,
 "createdate": 1575522059307
 },
 "associations": {
 "DEAL": [
 "deal_0000735706"
 ],
 "PRODUCT": [
 "xx-AM03"
 ]
 }
 }
 ]
}

```

With the above code, DEAL got created with empty LINE\_ITEMS. Please suggest me what’s going wrong.

Thanks,

Mahesh.S

---

<div class="post-metadata">

**Author:** ![jackcoldrick](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jackcoldrick/32/5119_2.png) [@jackcoldrick](https://community.hubspot.com/u/jackcoldrick)\
**Post date:** [December 5, 2019, 8:25am UTC](https://community.hubspot.com/t/line-items-are-not-creating-every-time-via-ecommerce-bridge-api/17569/2 "2019-12-05T08:25:18Z")

</div>

Hi @Mahesh1250,

Thanks for the detailed post this helps a lot. I’ve looked through it and I cannot see anything immediately wrong with what you are sending into HubSpot. I’ve also recreated your test using the same timestamps and I am seeing line items being created on my order (see below):

 ![line-item-on-deal.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/c/0/c022f3a6feb95aacad83a00b2c2969017dea4dc2.png)

The above is the result of the following PUT request:

ENDPOINT (send sync message):

`https://api.hubapi.com/extensions/ecomm/v2/sync/messages?hapikey={{apikey}}`

PAYLOAD:

```auto
{
 "storeId": "store-1",
 "objectType": "LINE_ITEM",
 "messages": [
 {
 "action": "UPSERT",
 "changedAt": "1575522059307",
 "externalObjectId": "LINEITEMX101",
 "properties": {
 "external_price": 100,
 "external_quantity": 2
 },
 "associations": {
 "DEAL": [
 "deal_0000735706"
 ],
 "PRODUCT": [
 "PRODUCT001"
 ]
 }
 },
 {
 "action": "UPSERT",
 "changedAt": "1575522059307",
 "externalObjectId": "LINEITEMX102",
 "properties": {
 "external_price": 100,
 "external_quantity": 1
 },
 "associations": {
 "DEAL": [
 "deal_0000735706"
 ],
 "PRODUCT": [
 "PRODUCT002"
 ]
 }
 }
 ]
}

```

My recommendation at this point would be to use the “[Check sync status of an object](https://developers.hubspot.com/docs/methods/ecommerce/v2/check-sync-status)” endpoint to ensure the LINE ITEMS are being correctly associated to the deal. This is assuming that you are seeing blank LINE ITEMS on the DEAL object. Your request would look something like this:

ENDPOINT:

`GET https://api.hubapi.com/extensions/ecomm/v2/sync/status/store-1/LINE_ITEM/lineItem_xx-SM-060?hapikey={{apikey}}`

If there has been an error, it will appear in the errors array in the response and an erroredAt field will be present. If you could share this error (if any) for the 3 line items you are attempting to create that would be great!

Regards,

Jack

---

<div class="post-metadata">

**Author:** ![Mahesh1250](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mahesh1250/32/97852_2.png) [@Mahesh1250](https://community.hubspot.com/u/Mahesh1250)\
**Post date:** [December 9, 2019, 2:52am UTC](https://community.hubspot.com/t/line-items-are-not-creating-every-time-via-ecommerce-bridge-api/17569/3 "2019-12-09T02:52:33Z")

</div>

Hi @jackcoldrick,

Thanks for the response… We got a solution for this as stated below.

I’m creating LINEITEM with externalObjectID as **“Lineitem\_” + xx123** (here xx123 is productCode). So, here there is a chance of getting duplicates if I order the same product(xx123) in another Order - so, it’s not creating a new Line-item for new Deal.

Now, I fixed by adding an **order code** to it to make it unique every time. Like

\*\*Lineitem\_

productCode

\_orderCode\*\*

LineItem :

**Lineitem\_xx123\_00012345**

```auto
{
 "storeId": "store-1",
 "objectType": "LINE_ITEM",
 "messages": [
 {
 "action": "UPSERT",
 "changedAt": "1575522059307",
 "externalObjectId": "Lineitem_xx12345_0012345",
 "properties": {
 "external_price": 100,
 "external_quantity": 2
 },
 "associations": {
 "DEAL": [
 "deal_0000735706"
 ],
 "PRODUCT": [
 "PRODUCT001"
 ]
 }
 },
 {
 "action": "UPSERT",
 "changedAt": "1575522059307",
 "externalObjectId": "Lineitem_xx12326_0012345",
 "properties": {
 "external_price": 100,
 "external_quantity": 1
 },
 "associations": {
 "DEAL": [
 "deal_0000735706"
 ],
 "PRODUCT": [
 "PRODUCT002"
 ]
 }
 }
 ]
}

```

Thanks for HubSpot Technical Support Team\*\*(& Abigail Chia)…\*\*Great Support.

Thanks,

Mahesh.S
