Have your say in Community Polls: What was/is your greatest motivation to start your own business?
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.

Issue with create orders via API

Issue with create orders via API

kbeat
Visitor
3 0 0

I use Laravel with BasicShopifyAPI to create the orders and the code seems to be working fine - orders are created as expected.

 

Recently, I've added a new partner shop to my production site (using private apps). The partner has set 'Orders' permission to 'Read and Write' and my code can successfully parse the products, product listings, and the list of existing orders. But whenever I try to create a new order by calling POST admin/orders.json, nothing is created.

 

I receive no errors. Instead, the response contains the list of all of the orders. Looks like I call GET instead of POST but I checked that multiple times and pretty sure that the POST method is used.

 

Then I realized one more thing: when I try to run the same code from my local computer, everything works fine. The problem exists only on production but I have rechecked all the environment configuration and the versions of libraries and found nothing there.

 

Here's my request for reference:

 

 

{
	"order":{
		"line_items":[
			{
				"variant_id":XXXXXXXXXXX,
				"quantity":1,
				"total_discounts":0,
				"price":79
			}
		],
		"landing_site":"https:\/\/mysite.com",
		"email":"tester@test.com",
		"customer":{
			"first_name":"Tester",
			"last_name":"Tester",
			"email":"tester@test.com"
		},
		"tags":[
			"test"
		]
	}
}

 

 

 

and the response is

 

 

 

{
	"errors":false,
	"response":{"GuzzleHttp\\Psr7\\Response":[]},
	"status":200,
	"body":{
		"Osiset\\BasicShopifyAPI\\ResponseAccess":{"orders":[...all of the orders are listed here...]}
	}
}

 

 

 

Replies 4 (4)

awwdam
Shopify Staff
249 42 38

Hey @kbeat, would you be able to share an example of an x-request-id response header value returned for a request where this unexpected behaviour is present. With that I can absolutely take a closer look at our logs and pass back any insights or next steps! - Cheers

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

kbeat
Visitor
3 0 0

hey @awwdam, thanks for your reply.

 

I have made another call to the shop and here's the data you asked for:

X-Request-ID : c1e26a08-da09-4109-9b4c-0e7d6e2b2ea6

 

I hope it helps.

kbeat
Visitor
3 0 0

Hey @awwdam, sorry for bothering but we still have this issue and I was wondering if you had a chance to look at my request.

 

Thanks.

awwdam
Shopify Staff
249 42 38

Hey @kbeat,

Thanks for your patience in waiting on my reply!

I was able to dig deeper here and found the logs linked the ID you shared - this was logged as a GET method to the /admin/api/2021-07/orders.json endpoint in our system. I simulated several REST Order API requests (POST, PUT, GET) manually with an API client as well as cURL to be sure - but found no issue with our API. 

From my understanding in the example shared the intention was a POST request, so my suggestion would be working through your apps configuration again, specifically referencing the documentation for any libraries in use.

Beyond that, you mentioned this was third-party library so I would consider looking for insights, open/related issues, or creating your own in their GitHub repos as next steps. For convenience, we have our first-party and some third-party libraries listed, each with links to GitHub. 

Hope you are able to get this figured out soon! - Best

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog