6

Guys I want to update order status using API. I am using this api to change the order status but it's not working:

http://dev-jawed.com/index.php/rest/V1/orders

{
"status" : "Out-for-delivery",
"entity" : 1,
"items": {
 "order_id" : 1
 }
}

Any help will be appreciated.

Kishan Patadia
5,6393 gold badges26 silver badges36 bronze badges
asked Apr 13, 2017 at 8:38

3 Answers 3

8

I think a better answer is to use the following api entry point

("/rest/V1/orders/{orderId}/comments", Method.POST);

pass the StatusHistory object in the post body, setting the appropriate fields to update the order status.

{
 "statusHistory": {
 "comment": "string",
 "createdAt": "string",
 "entityId": 0,
 "entityName": "string",
 "isCustomerNotified": 0,
 "isVisibleOnFront": 0,
 "parentId": 0, <-- This is the Order ID
 "status": "string",
 "extensionAttributes": {}
 }
}
Mukesh Chapagain
5,5235 gold badges42 silver badges52 bronze badges
answered May 6, 2019 at 17:24
3
  • FYI: not all of the fields are required, you can read which ones are required in the documentation Commented Nov 15, 2019 at 16:59
  • When i am using this api order state is not changing can plz advise Commented Oct 26, 2021 at 14:53
  • As @Sebastian said above, but new link here: magento.redoc.ly/2.3.7-admin/tag/ordersidcomments#operation/… Commented Jun 15, 2022 at 14:31
6

If you look at the swagger api documents (either on your local machine at /swagger or at the devdocs). You should find the API V1/orders. If you are using your local version you will also have the button to try to calls direct from swagger which is nice for debugging. From looking through the documents you should be able to post something like the following to the api.

{
 "entity": {
 "entity_id": 0,
 "status": "string"
 }
}

Remember to replace the entity_id with the correct order id and the status with the status you would like to change to.

answered Apr 13, 2017 at 9:32
2
  • This will create problems with increment_id (as experienced in Magento 2.2) - order's increment id will be changed (from scope 1 1000000005, to scope 0 (admin) 000000008). Commented Jan 4, 2018 at 12:43
  • @David Manners, is there any pattern that we can update staus more than one order in a single API call? Commented Jul 26, 2019 at 9:14
2

You can do this:

PUT /V1/orders/create

'entity' => [
 'entity_id'=> 1,
 'increment_id' => '000000001',
 'status'=> 'processing',
]

You currently (v 2.1.*) get the same result with calls:

PUT /V1/orders/create

https://github.com/magento/magento2/blob/24f2f071267f9e5ba0d5428b75fcbc76e6ef5b55/app/code/Magento/Sales/etc/webapi.xml#L64

POST /V1/orders

https://github.com/magento/magento2/blob/24f2f071267f9e5ba0d5428b75fcbc76e6ef5b55/app/code/Magento/Sales/etc/webapi.xml#L256

Rohan Hapani
17.6k9 gold badges57 silver badges99 bronze badges
answered Aug 28, 2017 at 8:52
1
  • Is there any pattern that we can update staus more than one order in a single API call? Commented Jul 26, 2019 at 9:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.