product import

Highlighted
New Member
7 0 0

Hi,

why does this curl not work?

curl -X POST https:...myshop.com/products.json --data '{"product":{"title":"BurtonCustomFreestyle151","body_html":"Goodsnowboard","vendor":"Burton","product_type":"Snowboard","images":[{"src":"http://example.com/rails_logo.gif"}]}}'

with postman it works?

Thanks
King regards
R

 

0 Likes
Highlighted
Shopify Partner
577 39 113

What response are you getting back with the curl request? And how are you passing along your credentials with the curl request? Compare that against Postman and therein lies the difference!

0 Likes
Highlighted
New Member
7 0 0

{"errors":{"product":"Required parameter missing or invalid"}}

0 Likes
Highlighted
Shopify Partner
577 39 113

You don't appear to be specifying the Content-Type in the curl call. 

-H 'Content-Type: application/json'

 

0 Likes
Highlighted
New Member
7 0 0

Thanks a lot but same error also with  "-H 'Content-Type: application/json'"

 

Thaknsbest regards

R

0 Likes
Highlighted
Shopify Partner
577 39 113

If you can fire up Fiddler you can see exactly what is being passed out of the Postman session as well as the curl session. Likely to do with the body payload's quotes and whatnot I'm guessing...

0 Likes
Highlighted
Shopify Partner
577 39 113

I have curl for Windows and the statement below worked just fine. Of course redacted the API creds in the URL.

curl -X POST "https://{api_key}:{api_secret}@diamond-cellar.myshopify.com/admin/products.json" -H "Content-Type: application/json" -d  "{\"product\":{\"title\":\"BurtonCustomFreestyle151\",\"body_html\":\"Goodsnowboard\",\"vendor\":\"Burton\",\"product_type\":\"Snowboard\",\"images\":[{\"src\":\"https://twitter.com/rails/status/689480911432249345/photo/1\"}]}}"
2 Likes