How to close Work Order using REST API

viktormay
Kilo Contributor

Hello.

I'm trying to close work order via REST API explorer (for testing) .

Using dedicated user for that. With all the roles (admin). Work orders are created with that user also.

I try to use these fields in PUT request to wm_order table:

{"work_notes":"test","state":"3","u_close_code":"1"}

PUT https://instance.com/api/now/table/wm_order/HereIsSysId

I get 200 OK.

The problem is that everything updates but state.

I can't change it at all via PUT. Other fields like close notes modified just fine.

What should i look into?

UPDATE: Work Order Tasks doesnt update State as well with PUT

12 REPLIES 12

prashantnagaral
Kilo Guru

Hi May,



I suspect process lifecycle for work order is set to "task driven" hence first all related work order tasks has to be closed which automatically set work order to closed complete .



Hit like, Helpful or Correct depending on the impact of the response


Regards


Prashant


Thanks for response.


Yes, i tried to close task too.



{"state":"3","close_notes":"testttt","u_close_code":"1"}



State doesn't change, so work order task doesnt close, so work order doesn't close.


Status code 200 and state stays like this in response:


"state": "16",


Mike Allen
Mega Sage

Try to go to the record and close it manually.   It will tell you if all the prerequisites for closing the item have been met.   You will get a much clearer picture as to what is going on.


srinivasthelu
Tera Guru

Hi Viktor,



Are you able to close the same work order manually through UI?



It worked for me through REST API, so was wondering something specific to your instance preventing it