Creating approval for a specific incident using REST api in Python.

Ibrahim10
Kilo Explorer

Hi,

i have a use case where i need to create the approval for a specific incident programatically.

i am trying to do this using the REST Api in python by following code snippet:

import requests
import json

user='admin'
pwd=''

url='https://dev68600.service-now.com/api/now/table/sysapproval_approver'
headers = {"Accept":"application/json"}


mydata={'state':'Not yet Requested',"approver":"971e029d983500107f2c2ed01a1f167d","source_table":"incident","sysapproval":'73908958dbf51010aa4df53a29961918','docuemnt_id':"73908958dbf51010aa4df53a29961918"}
response = requests.post(url, auth=(user, pwd), headers=headers ,data=json.dumps(mydata))

With the above i am able to create a record in the approval table but having the following problems:

  1. not able to add the approver by adding sys_id/user_id from the users table?
  2. not able to link this approval to the incident record i wanted to?

i have attached the images for the created records in the approval table.

find_real_file.png

find_real_file.png

in the above image linked incident is not the one for which i provided sys_id in my_data and passed as parameters.

Please help me in this problem.

Thanks for your time.

Regards

6 REPLIES 6

Hi Ibrahim,

Did you ever figure this out? I am also trying to create approvals for sc_req_item via REST API, and get the same results: approval record is created, but approver and sysapproval and document_id are not populated.

Thank you

Liam Barksdale

In the meantime, I think I figured it out (or at least some version of 'it'). There are WRITE ACLs on those fields with the role of 'maint' which seems to be restricting those fields, but just via REST API ... so I ended up creating new WRITE ACLs for those fields, and gave them the role of approval_admin, and then gave that role to an assignment group that contained the user (service account) that is creating the approvals via REST API. I am now able to create approvals on RITMs via REST.