Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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
I am trying to create an order using post man. Considere that I am truly using POST instead of GET.
The error as you can see is that the request responses with status 200 and the body is orders instead of order. And the order is not created.
Is there anyone here that knows when happens this kind of things? The API should be more descriptive with the error responses.
Fact: I have used the same payload with another store and it works. I have the write_order permission in mi developer app. What am I missing in mi configuration?
Solved! Go to the solution
This is an accepted solution.
I found the solution. I am using a custom domain name, let's say: "myshop.com" so in my request I use:
https://myshop.com/admin/api/2023-04/orders.json
That's the mistake. Unfortunately postman don't warn us about that but the request actually is returning a 301 redirect. So apparently the default response after the redirect is a GET. I don't know why. The way I noticed the error was by executing the request via CURL in the terminal.
Do the POST request in the terminal and you will see something like this:
curl -i -X POST -H "Content-Type: application/json" -H "X-Shopify-Access-Token: " -d '{"order":{"line_items":[{"variant_id": ,"quantity":1}],"customer":{"id": },"financial_status":"pending"}}' https://myshop.com/admin/api/2023-04/orders.json
HTTP/2 301
date: Fri, 07 Jul 2023 03:15:44 GMT
content-type: text/html; charset=utf-8
location: https://realdomain.myshopify.com/admin/api/2023-04/orders.json
....
So replace "myshop.com" with "realdomain.myshopify.com" and it will work!!
This is an accepted solution.
I found the solution. I am using a custom domain name, let's say: "myshop.com" so in my request I use:
https://myshop.com/admin/api/2023-04/orders.json
That's the mistake. Unfortunately postman don't warn us about that but the request actually is returning a 301 redirect. So apparently the default response after the redirect is a GET. I don't know why. The way I noticed the error was by executing the request via CURL in the terminal.
Do the POST request in the terminal and you will see something like this:
curl -i -X POST -H "Content-Type: application/json" -H "X-Shopify-Access-Token: " -d '{"order":{"line_items":[{"variant_id": ,"quantity":1}],"customer":{"id": },"financial_status":"pending"}}' https://myshop.com/admin/api/2023-04/orders.json
HTTP/2 301
date: Fri, 07 Jul 2023 03:15:44 GMT
content-type: text/html; charset=utf-8
location: https://realdomain.myshopify.com/admin/api/2023-04/orders.json
....
So replace "myshop.com" with "realdomain.myshopify.com" and it will work!!