# Create Line\_Items API returns "Bad Request"

**URL:** <https://community.hubspot.com/t/create-line-items-api-returns-bad-request/12501>\
**Category:** APIs & Integrations\
**Created:** [December 19, 2018, 12:51am UTC](https://community.hubspot.com/t/create-line-items-api-returns-bad-request/12501 "2018-12-19T00:51:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam5923](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/adam5923/32/47092_2.png) [@adam5923](https://community.hubspot.com/u/adam5923)\
**Post date:** [December 19, 2018, 12:51am UTC](https://community.hubspot.com/t/create-line-items-api-returns-bad-request/12501/1 "2018-12-19T00:51:05Z")

</div>

I am trying to create line\_items to be later associated to a deal, but get “Bad Request” response.  
The same response comes back for create single as well as batch line\_items.

Use this sample, as well as my own ApiKey:

[https://api.hubapi.com/crm-objects/v1/objects/line\_items?hapikey=demo](https://api.hubapi.com/crm-objects/v1/objects/line_items?hapikey=demo)

Example POST JSON:

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [December 19, 2018, 9:09pm UTC](https://community.hubspot.com/t/create-line-items-api-returns-bad-request/12501/2 "2018-12-19T21:09:47Z")

</div>

Welcome, @adam5923!

Did you mean to include example `POST` JSON? It seems to have been cut off. Could you share your Hub ID as well?

---

<div class="post-metadata">

**Author:** ![adam5923](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/adam5923/32/47092_2.png) [@adam5923](https://community.hubspot.com/u/adam5923)\
**Post date:** [December 19, 2018, 9:41pm UTC](https://community.hubspot.com/t/create-line-items-api-returns-bad-request/12501/3 "2018-12-19T21:41:12Z")

</div>

No, I only meant to say that I was using the sample json from the API manual. Also tried json against our company hubspot.

---

<div class="post-metadata">

**Author:** ![adam5923](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/adam5923/32/47092_2.png) [@adam5923](https://community.hubspot.com/u/adam5923)\
**Post date:** [December 19, 2018, 9:43pm UTC](https://community.hubspot.com/t/create-line-items-api-returns-bad-request/12501/4 "2018-12-19T21:43:26Z")

</div>

Please let me know if this sample from API manual works for you, it does not for me:  
[https://api.hubapi.com/crm-objects/v1/objects/line\_items?hapikey=demo](https://api.hubapi.com/crm-objects/v1/objects/line_items?hapikey=demo)

Example POST JSON:  
[  
{  
“name”: “hs\_product\_id”,  
“value”: “1642736”  
},  
{  
“name”: “quantity”,  
“value”: “50”  
},  
{  
“name”: “price”,  
“value”: “9.50”  
},  
{  
“name”: “name”,  
“value”: “A custom name for the product for this line item. Discounting 5% on bulk purchase.”  
}  
]

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [December 19, 2018, 9:59pm UTC](https://community.hubspot.com/t/create-line-items-api-returns-bad-request/12501/5 "2018-12-19T21:59:53Z")

</div>

Thanks for clarifying, @adam5923.

To be transparent, that’s not how our example JSON is meant to be used. While an API demo account exists, its objects and values have been modified so many times by public users that many endpoints won’t work with the `hapikey=demo` value and the example JSON provided.

Instead, it’s best practice is to use a [test account’s](https://developers.hubspot.com/docs/faq/how-do-i-create-a-test-account) API key as you’ll have access to all the necessary tools and scopes without the interference of other users.

You mention that you tried the JSON against your production account, but if you simply pasted it into a client and sent the request, it would also fail because you wouldn’t have a product with an `hs_product_id` equal to `1642736`.

If you experience the same issue trying to update one of your own products (with the correct `hs_product_id`), please share the Hub ID and `POST` JSON and I’ll take a look.

---

<div class="post-metadata">

**Author:** ![adam5923](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/adam5923/32/47092_2.png) [@adam5923](https://community.hubspot.com/u/adam5923)\
**Post date:** [January 4, 2019, 2:32am UTC](https://community.hubspot.com/t/create-line-items-api-returns-bad-request/12501/6 "2019-01-04T02:32:10Z")

</div>

Hi Isaac, I am getting “Bad Request” on other PUT calls to create association between Deal and Company.  
How can I get more details on what is wrong with the request? It is a simple JSON sent.

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [January 4, 2019, 4:46pm UTC](https://community.hubspot.com/t/create-line-items-api-returns-bad-request/12501/7 "2019-01-04T16:46:00Z")

</div>

Hey, @adam5923.

If this is a different, request, could you please share the following:

1. Your Hub ID.
2. The full request URL you used, including the method. (Do not include any API keys.)
3. The raw request body, including the headers.
4. The _full_ error you received from HubSpot, including the status code.
