create order via api

Highlighted
Tourist
5 0 1

I am attempting to create a test order via the orders api but am receiving a HTTP/2 400 status from the server

 

Follows is a capture of the server response

 

shopifyServerResponse.png

 

Thank you

0 Likes
Highlighted

Hello 

Refer this url to create order using shopify API:
https://help.shopify.com/en/api/reference/orders/order#create

Want to modify or incorporate custom changes on store, Hire us.
If helpful then please Like and Accept Solution .
Email: pallavi@oscprofessionals.com
Skype : oscprofessionals-87
Free Review and advice for sale on store | Shopify Private App | Custom Theme Development | Custom Modifications In To Shopify Theme | SEO & Digital Marketing | Site Speed Optimization | Performance Site Audit
0 Likes
Highlighted
Tourist
5 0 1

Thank you for the response. I have followed the documentation and also searched the internet for solutions. I see in the response headers 'HTTP/2 400' as status, which means 'Bad Request' and 'Required parameter missing or invalid'. Follows is the string submitted to the server: 

 

{"order":{"email":" ","financial_status":"pending","line_items":[{"title":"Big Brown Bear Boots","price":100,"grams":"1300","quantity":2,"tax_lines":[{"price":13.5,"rate":0.06,"title":"state tax"}]}],"transactions":[{"kind":"authorization","status":"success","amount":200}]}}.

 

Thank you

0 Likes
Highlighted
Shopify Staff
Shopify Staff
521 67 79

Hey @kschuster,

 

How are you sending the request? It's coming through malformed:

 

Param: {"order":{"email":" ","financial_status":"pending","line_items":_{"title":"Big Brown Bear Boots","price":100,"grams":"1300","quantity":2,"tax_lines":_{"price":13.5,"rate":0.06,"title":"state tax"}_}_,"transactions":_{"kind":"authorization","status":"success","amount":200}_}}


Value:
nil

0 Likes
Highlighted
Tourist
5 0 1

Hi, the request is being sent via curl. I can see the extra characters (underscores) and linefeeds in what you posted. Apparently the array is being encoded incorrectly before being sent. Do you have any suggestions?

 

Kurt

0 Likes
Highlighted
Shopify Staff
Shopify Staff
521 67 79

Are you able to share the relevant code?

0 Likes
Highlighted
Tourist
5 0 1

Follows is what is being sent:

 

{"order":{"email":" ","financial_status":"pending","line_items":[{"title":"Big Brown Bear Boots","price":100,"grams":"1300","quantity":2,"tax_lines":[{"price":13.5,"rate":0.06,"title":"state tax"}]}],"transactions":[{"kind":"authorization","status":"success","amount":200}]}}

 

It is an array encoded using json_encode() and sent using curl.

 

Thank you for your assistance.

 

Kurt

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
521 67 79

The data looks fine. I suspect it's a curl syntax issue. Can you share a snippet?

0 Likes
Highlighted
Tourist
5 0 1

Hi Scottydont,

 

Figured it out -- the header in the cURL settings did not include 'Content-Type:application/json'.

 

Will post fix to GitHub and others.

 

Kurt

1 Like