How to change the state of work order task by Rest API?

Piyush Sharma
Kilo Explorer

Hi Everyone

I am currently new in Service Now and working on Work Order. I have set up a work order template which contain 4 dependency tasks and i want to change the state of task by api. I come to know that after assigned task to a user state change to 17, when user accept it, then state change to 18 and when it start working on the task it change to 19 and at last when task is complete it change back to 3. 

So i am finding a way through which i change it state after user accept, like to 18 via REST API.  When i sending the data via REST API i am getting response 200 but state remain same 16. I have also tried to close the task via api by sending data in body: 

{"work_notes":"close task","state":"3","u_close_code":"1"} but again i have received response 200 ok but there is no change in state it is still 16.

I am using a put request by using a url: https://xxxxxxxx.service-now.com/api/now/v1/table/wm_task/ae02059adbf213002471dec0cf96192d

and username and password is also authorized + also have itil role through which he can change the state, could any one please update me is any business rule is blocking it? 

Also in UI i am able to accept, cancel and start the task, but issue appears only when i requesting it via REST API.

 

Any help would be appreciate!

 

9 REPLIES 9

Raju Koyagura
Tera Guru

If you are getting 200 message as response status, the REST message is proper however you have to verify the mandatory fields to change one state to another state. For example to Close, it required work notes and also to move to any other state it required Dispatch group. If everything is set then REST updates the record state else it gives 200 but sate will not update. 

Moreover Work Order Task allowed web services configuration. 

Hi @raju thanks for your valuable response where as i have already assigned dispatch group to this task as well as other task of this work order. I have also tried by sending work notes, i have tested it not only to close this task but to accept, start etc. Could you please elaborate web service configuration, as from my side to sending a request via web service i am using all required configuration.

Have you considered using PATCH instead of PUT?

Hi i have also tried it via patch as well but it didn't work, also what about dispatch group which he mention. I also have to send dispatch_group which consist link and value property?

Do you think any business rule creating this issue?

I am trying to update status from accepted(17) to start(18)