Admin API - Order not updated with 200 PUT request

surefootme
New Member
3 0 0

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?

0 Likes
_JB
Shopify Staff
Shopify Staff
750 87 165

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

0 Likes
Greg_Kujawa
Shopify Partner
965 80 204

Using Postman, are you adding Content-Type: application/json as a header? And the body is defined as raw: JSON?

0 Likes
surefootme
New Member
3 0 0

Thanks for the reply, I figured it out! I was using the full domain of the site to hit the API endpoint, rather than shop.myshopify.com as the domain. Things are working as expected now!

0 Likes
KDPC
New Member
1 0 0

you need a print provider api

0 Likes
Tale
New Member
4 0 0

How did you make the put request, can u give me an example of code?

0 Likes
Greg_Kujawa
Shopify Partner
965 80 204

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"
    }
}

 

0 Likes
Tale
New Member
4 0 0

is this using postman? 

0 Likes
Greg_Kujawa
Shopify Partner
965 80 204

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?

Tale
New Member
4 0 0

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 

0 Likes