Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Why am I receiving a bad request when creating a product with the Admin API?

Why am I receiving a bad request when creating a product with the Admin API?

APInifynMYApp
Shopify Partner
1 0 0

Hi All!

I'm successfully performing a GET of all products via the Admin API. But when I try to create a product, I keep getting BAD REQUEST... and I don't know why. What am I missing? 

Here's what I'm trying:

JSON

{"product":{"body_html":"<strong>Good snowboard!</strong>","product_type":"Snowboard","status":"draft","title":"Burton Custom Freestyle 151","vendor":"Burton"}}

 

HEADER

 -H "Method: POST" -H "Content-Type: application/json" -H "X-Shopify-Access-Token: REMOVEDFORSECURITY"

 

URL

https://REMOVEDFORSECURITY.myshopify.com/admin/api/2024-01/products.json

 

cURL Sent:

 -H "Method: POST" -H "Content-Type: application/json" -H "X-Shopify-Access-Token: REMOVEDFORSECURITY" -d {"product":{"body_html":"B<strong>Good snowboard!</strong>","product_type":"Snowboard","status":"draft","title":"Burton Custom Freestyle 151","vendor":"Burton"}} -D $responseHeader

 

Response:

Bad Request

Reply 1 (1)

jmitchtx
Visitor
1 0 0

Make sure your JSON is well-formed and escaped, see this stackoverflow article for more info.