Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

"Required parameter missing or invalid" error when creating an order

Solved

"Required parameter missing or invalid" error when creating an order

Development_Te3
Tourist
3 1 3

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!

 

 

 

Accepted Solution (1)
Development_Te3
Tourist
3 1 3

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.

View solution in original post

Replies 4 (4)

oscprofessional
Shopify Partner
16407 2444 3196

Hello 

 

Please refer the below link ;-

https://help.shopify.com/en/api/reference/orders/order#index-2019-07

Hire us | Pass Core Web Vital | B2B Wholesale Experts | Claim Your Free Website Review |
Connect with Us: WhatsApp | Skype: oscprofessionals-87 | Email: pallavi@oscprofessionals.com |
Custom Shopify SolutionsPrivate Apps, Theme Customization & SEO | Digital Marketing |
OSCP Apps: Discount Suite | Wholesale App | Bundle & Upsell | Shipping Discount | and more...
Development_Te3
Tourist
3 1 3

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!

 

Development_Te3
Tourist
3 1 3

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.

steamroller
Shopify Partner
8 0 4

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.