3

I want to develop new module for changing order status using Api in magento 2.3.5 so can anyone have idea then please share with me. I want to create order status and change it using Api.

asked Jun 16, 2020 at 10:17

5 Answers 5

2

I am using Integromat for automatic change order status. But if I do this API call than I recieve 400: Request method is invalid. I tried to use different methods like PATCH, PUT and still get 400.

My connection is functional, beacause other actions like Find orders is functional. But dont know why this api calls doesnt work(any custom API calls).

URL: /rest//V1/orders/

Header: Content-Type: application/json Authorization: Bearer auth.token

Body:

{
 "entity": {
 "entity_id": xxxxx,
 "state": "processing",
 "status": "prijata_platba"
 }
}

Could you help me with this? Thank you

answered Apr 13, 2021 at 14:47
1
  • Thank You for your solution. Commented Apr 29, 2021 at 6:24
3

You can use the rest webservice: http://yoursite.com/index.php/rest/V1/orders

On the body you just have to pass:

{
 "entity": 
 {
 "entity_id": your order id, 
 "state": your state,
 "status": your status
 }
}

Don't forget to also include in the http header the following fields:

Content-Type: application/json

Authorization: Bearer Your authentication token

Any more help or explanation needed feel free to ask ;)

try this on postman, it's a lot easier to test and debug !

answered Jun 16, 2020 at 10:27
5
  • I want to develop api for this thing Commented Jun 16, 2020 at 11:18
  • 1
    What do you mean by developing API? You want to make a C# function to call the Webservice? Commented Jun 16, 2020 at 11:26
  • yes i want to C# function to call the webservice Commented Jun 16, 2020 at 11:31
  • But which key prevails, the status or state? Because when I provide the state key it won't accept it, but will return a 200 response if it only has the status one. So I guess the former one is not required. Is that correct? Commented Mar 12, 2021 at 9:40
  • Thank you for your solution. Commented Apr 29, 2021 at 6:24
2

Try this params. It is working.

{
 "entity": {
 "entity_id": 1,
 "state":"processing",
 "status": "processing"
 }
}

Check mapping in sales_order_status_state.

Happy Coding.

answered Jun 16, 2020 at 10:25
2
  • Hi, I want to develop api for that Commented Jun 16, 2020 at 11:19
  • Thank you for your solution. Commented Apr 29, 2021 at 6:24
0

You can call POST V1/orders/{orderID}/comments

Example:

Website URL = example.com

Store code = default

Order ID = 1234

API URL will be: example.com/rest/default/V1/orders/1234/comments

API Method = POST

REQUEST BODY

{
 "statusHistory" : {
 "comment": "Your comment...",
 "is_customer_notified": 0,
 "is_visible_on_front": 0,
 "parent_id": 1234, <-- This is the Order ID
 "status": "complete"
 }
}

https://developer.adobe.com/commerce/webapi/rest/quick-reference/

answered Apr 4, 2024 at 15:15
1
  • This method no longer works starting from Magento 2.4.7. Extract from the 2.4.7 changelog; "The REST V1/orders/{id}/comments endpoint no longer changes the status of an order when trying to add a comment to a pending order’s status. It now gives an informative error. Previously, this endpoint changed the order status when adding a comment." Commented Apr 18, 2024 at 8:20
0

I can confirm that from 2.4.7 you can no longer change the order status via the comment api: https://github.com/magento/magento2/commit/aa01106ddc3c8586aa588d1932bc2904a4cb9d79

I am not sure what the alternative is thou

answered Jul 17, 2024 at 15:09

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.