A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello,
I've been trying to update an open order to include the tag imported via the rest API.
My API body matches the documentation exactly from what i can see however i seem to be getting a 400 response.
PUT admin/api/2019-10/orders/186023031616.json
{ "order": { "id": 186023031616, "tags": "Imported" } }
When executing the below i get the following response:
{ "errors": { "order": "Required parameter missing or invalid" } }
If there's any more information i can give to help find a resolution, let me know!
Solved! Go to the solution
This is an accepted solution.
Hey @aaronroach ,
In PostMan, change the type of the Body of your PUT request from "Text" to "JSON". Also make sure that the header of "Content-Type"="application/json" has been added to your request. That should resolve your issue.
Here are some screenshots that demonstrate what I am talking about:
To learn more visit the Shopify Help Center or the Community Blog.
Hi @aaronroach ,
I was able to perform this exact same PUT request for my test store, and I can verify from my end that it worked correctly and my order was updated to have the new "Imported" tag. See the following screenshot:
Perhaps your error may have come from a formatting issue. If you are still experiencing this same error, could you please provide me with the value of the "X-Request-ID" header from the API Response? With this value I can go through the logs on our end and see why this error may be occurring
To learn more visit the Shopify Help Center or the Community Blog.
Hi @hassain ,
Yeah, this seems like a very strange one, I cant seem to see any formatting errors, as what i copied above was exactly what i am sending (all be it with a different ID)
An example failure is X-Request-Id: 960bb787-aaec-4abe-979f-7d1bf926ee2e
Thanks for your help!
Hey @aaronroach ,
I was able to find your specific request with the 400 error response through the Shopify platform logs, but unfortunately I was unable to find any information that would indicate why the error was being thrown.
Could you verify you are passing the body of with the PUT request? Or using the correct API Access Token with your request? If you could provide a screenshot of the agent you are using to make the request (i.e. POSTMan, Insomnia, cURL) or provide the code that is generating the request, that could help. Thanks
To learn more visit the Shopify Help Center or the Community Blog.
Hi @hassain ,
I'm using VB.net to issue the request, however because i was experiencing the issue, i tried to debug it in Postman, however i'm getting the same issue. i'm passing a basic authorisation in the header, and presume its working as I'm not getting any authorisation errors. Using the same token method and auth, i am able to retrieve orders.
Its definitely being sent as a PUT as seen below:
This is an accepted solution.
Hey @aaronroach ,
In PostMan, change the type of the Body of your PUT request from "Text" to "JSON". Also make sure that the header of "Content-Type"="application/json" has been added to your request. That should resolve your issue.
Here are some screenshots that demonstrate what I am talking about:
To learn more visit the Shopify Help Center or the Community Blog.
Hi @hassain ,
Thanks for this, I completely overlooked that, adding the content type solved it!
Thanks for your help in resolving this issue, and your prompt replies!
This is a great post! I am looking to do this very thing, BUT, at the Thank you page or immediately after the order is placed.
Can anyone offer me advise in the best way to call the Shop's API post order placement?
I am thinking something like this...
Hey @MJaspan ,
You can look into the concept of Webhooks (https://help.shopify.com/en/manual/sell-online/notifications/webhooks). Webhooks are notifications that Shopify will fire out to your app whenever an event happens that your app is subscribed to. So for example, your app can subscribe to a store's "order/create" topic and then it will receive webhook notifications every time an order happens on that store.
Once you get the webhook notification, you can can then fire the PUT request with the Admin API to update that order to have a new tag (https://shopify.dev/docs/admin-api/rest/reference/orders/order#update-2020-01).
To learn more visit the Shopify Help Center or the Community Blog.
Thank you @hassain! I will keep this in mind. And, I was able to address it via Workflow. Thankfully my store is Shopify Plus, so we can take advantage of that.
Thank you for the feedback! Thank you for the API and Webhooks suggestion, that is definitely an acceptable solution. Thankfully, being that we are a Shopify Plus customer, we are were able to take advantage of the Workflow functionality. Easy to setup and it works like a charm! Thank you all so much.
i also had same problem.
its because when you have PUT you must mention type like this:
--header 'Content-Type: application/json'
then problem will be solved.
Thanks