I'm trying to update some order info after an order is created. I'm able to successfully authenticate with the API, but a PUT request doesn't update the fields like I'd expect. For example, trying to update the note field, the response is a 200 status code, but the response body does not contain the updated information:
PUT /admin/api/2020-04/orders/2146398797903.json
body
{ "order": { "id": 2146398797903, "note": "foo" } }
response
{ "order": { "id": 2146398797903, "closed_at": null, "created_at": "2020-03-31T11:59:55-05:00", "updated_at": "2020-04-03T12:58:29-05:00", "note": null, //... } }
I'm testing the API using Postman. Trying to authenticate using the "Authorization: Basic [base64 encoded username:password]" was unsuccessful. I have authenticated using the "X-Shopify-Access-Token" header, as explained here.
I suspect I'm missing a critical piece to be able to successfully update orders - any advice or resources to check out?
Hey @surefootme,
It's strange that you're getting a 200 response if the order isn't actually being updated. Can you try sending the request with the auth credentials in the URL? Like https://{{api_key}}:{{api_secret}}@shop.myshopify.com/admin/api...
Also please provide the X-Request-ID value from the response headers of your call, and I'll check our logs for more information.
JB | Developer 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
I thought the OP already did above. Here is another sanitized example, where I simply add a note to an existing order. Hope this helps!
PUT https://{my_shop}.myshopify.com/admin/api/2020-04/orders/1897779691572.json HTTP/1.1
Content-Type: application/json
Authorization: Basic {my_auth}
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Postman-Token: 50745ffe-9ff4-47f9-b657-76a711ef2160
Host: {my_shop}.myshopify.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 86
{
"order": {
"id": 1897779691572,
"note": "test-note"
}
}
As the PUT request header indicated, indeed it is. But the barebones request headers, the PUT URL, the PUT request body, etc. are generically applied regardless of what tool you are using to issue the request, right?
That's right, i am having hard time changing order phone number using put request, i am trying with js right now i wrote "get" request and got the order with response, but now i need to update it to admin with api call request, i am kinda new with shopify api so i am trying this on js syntax:
PUT /admin/api/2020-10/orders/450789469.json
{ "order": { "id": 450789469, "phone": "+15145556677" } }
$.ajax({
method: "PUT",
url: api_url_post,
data: {
"order": {
"id": hiddennumber,
"phone": "0000"
}
},
contentType: "application/json;",
crossDomain: true,
dataType: "json",
success: function (data, status, jqXHR) {
alert("success");// write success in " "
},
error: function (jqXHR, status) {
// error handler
console.log(jqXHR);
alert('fail' + status.code);
}
});
});
this returns undefiend ( the url link is variable )
sorry to bother
User | Count |
---|---|
13 | |
12 | |
6 | |
6 | |
5 |