How to request approval in change request through API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2022 12:15 AM
Hello, All.
I know this question already has been asked before, but I didn't find the correct answer or the solution is not working as expecting.
I'm trying to push "Request Approval" button on standard change request (see screenshot) through API or in other words move change request to "Autorize" state. Doing some web scraping I found the exact ID of the UI action of this button. Here's the code in Powershell:
$Params = @{
Headers = $GlobalHeaders
Method = "Post"
Body = @{
fields = @(@{
name = ""
})
} | ConvertTo-Json
Uri = "$ServiceNowSandboxInstance/api/now/ui/ui_action/f07eedb3cb200200d71cb9c0c24c9c3d?sysparm_table=change_request&sysparm_sys_id=[change_sys_id]&api=api"
}
Invoke-RestMethod @Params
The output shows status code: 201 (Created). But nothing happens to the change request.
Am I missing something or maybe there is another way to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2022 05:49 AM
The OOTB 'Request approval' UI action with the above sys_id is using client side code, but there is no user session, hence client side APIs like g_form would not work.
I would rather set-up a scripred Rest API and call that - you can then have the server-side equivalent of the UI action run in that custom scripted api.