Use of REST API to approve Request

GloriousWater
Giga Contributor

Hello. I am using the REST API to create and submit requests. 

In some cases, I will be creating several 100 requests containing multiple items that needs different approvals. Instead of having each person manually approve each item, is it possible to push them through the workflow / Approve them using the REST API ?

All help is appreciated!



1 ACCEPTED SOLUTION

Amit Gujarathi
Giga Sage
Giga Sage

Hi GloriousWater,

Hope yiou are doing well.

This is an intresting requirement.

Yes you can definately create a scripted rest api to approve the records but You would update the sysapproval_approver record. The trick becomes authenticating who is doing this. REST integrations typically don't come from a user, they come from a service account, so all approvals are done by the same person. From an audit perspective, this is a bad idea.

Steps:

  • Go to REST API explorer

find_real_file.png

  • select the table as sysapproval_approver
  • Use the PAtch API
  • Provide the payload as given in below :
{"state":"approved/rejected","approver":"sys_id of approver"}

 

Please mark correct if it helped.

 

Regards,

Amit Gujarathi

(Technomonk)


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use OOB Table API on Approval table for approving/rejecting the records.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Amit Gujarathi
Giga Sage
Giga Sage

Hi GloriousWater,

Hope yiou are doing well.

This is an intresting requirement.

Yes you can definately create a scripted rest api to approve the records but You would update the sysapproval_approver record. The trick becomes authenticating who is doing this. REST integrations typically don't come from a user, they come from a service account, so all approvals are done by the same person. From an audit perspective, this is a bad idea.

Steps:

  • Go to REST API explorer

find_real_file.png

  • select the table as sysapproval_approver
  • Use the PAtch API
  • Provide the payload as given in below :
{"state":"approved/rejected","approver":"sys_id of approver"}

 

Please mark correct if it helped.

 

Regards,

Amit Gujarathi

(Technomonk)


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Thanks 🙂 

Using the ODBC driver to extract information on specific request / items and then providing people with a list where they can quickly check if something is to be approved or not and then just read it in through the api to approve w/e needs approval. gonna save them quite a bit of clicking. 

 

For the audit issue, i suppose i can grant my users rest api roles and then create a script where they provide their credentials when running it. (Without credentials being saved in the script).