Create Line_Items API returns "Bad Request"


#1

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

Example POST JSON:


#3

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?


#4

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


#5

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

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


#6

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


#7

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.


#8

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.