Discussing APIs and development related to customers, discounts, and order management.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hi there,
I'm running into an issue where I am able to POST an order to Shopify through Postman, but when I try to recreate it in my app I get the following error:
{"errors":{"order":"Required parameter missing or invalid"}}
Below is my code:
var testOrder = { "order": { "email": "email10+TEST@gmail.com", "shipping_address": { "address1": "10 Erb St.", "city": "Toronto", "province": "ON", "country": "CA", "zip": "N2N 1N5", "company": null, "first_name": "JOE", "last_name": "TEST" }, "phone": null, "line_items": [ { "variant_id": 42331988931, "price": "300.0", "quantity": 1 } ], "discount_codes": [ { "code": "25%OFF", "amount": "25", "type": "percentage" } ], "tags": "27900202", "note": "test", "shipping_lines": [ { "title": "test", "price": "30.00", "code": "test" } ], "total_tax": "25.5" } }; var shopifyOrderOptions = { url: "https://{apikey}:{password}@{site}.myshopify.com/admin/api/2019-07/orders.json", headers : { 'Content-Type': 'application/json' }, data: testOrder request.post(shopifyOrderOptions, (err, res, body) => { if (err) { console.log(err); } console.log(body); });
Please let me know what I'm doing wrong. Thanks!
Solved! Go to the solution
This is an accepted solution.
Nevermind, I just had to change the 'data' parameter to 'body' and JSON.stringify() the value. It now posts sucessfully.
Hello Development_Te3,
Please refer the below link ;-
https://help.shopify.com/en/api/reference/orders/order#index-2019-07
Hi Pallavi,
I've been referring to this Order API documentation as well as the general API docs, and I may be missing something but I've been having trouble finding out how to properly format the request along with the correct headers, authentication, etc. I'm assuming this is what is giving me the error as it's successfully posting via Postman but not in my app. Or perhaps it's how I'm using the Request HTTP client. Would you be able to possibly shed some light on this? Sorry I should have been more specific in my initial question.
Thanks!
This is an accepted solution.
Nevermind, I just had to change the 'data' parameter to 'body' and JSON.stringify() the value. It now posts sucessfully.
For Googlers, remember that your API client (i.e. Postman) might not be formatting your body the way Shopify wants it, by default. (data-raw, etc.) Beware of the CURL gotchas with Postman if you are reading the CURL examples in the Shopify docs.