How to close Work Order using REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2017 03:59 AM
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
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2017 04:40 AM
I can't close Work Order in UI. No buttons for that action.
Yes, usually i close WO through Work Order Task.
And i could close Work Order Task but how can i get Work Order Tasks IDs which related to a specific Work Order?
GET for a specific Work Order doesn't provide Tasks IDs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2017 04:56 AM
I think you would have to write a REST scripted action for this. Feed it the sys_id of the Work Order, query the tasks, close them, then close the work order. You cannot do in REST what you cannot do in the UI, generally speaking. REST calls are simply HTTP calls to the system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2017 05:01 AM
Allright. This is the part where i stuck:
>Feed it the sys_id of the Work Order, query the tasks
No tasks in response!
And i tried to change task state with PUT - nothing happens. Only other fields are filled
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2017 05:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2017 09:18 PM
Thanks. But i think that if i can't close WO and WOT with REST API Explorer i won't be able to close it with Scripted REST API too