Multiple Task SCTASK under single RITM- REST API

Nanasaheb
Kilo Contributor

I use Python Script to create tasks in multiple categories, 

now i need REST API url which help me to create more TASKS under one RITM/REQ.

anyone did this before?


update:
I have one ritm with one task is present but i want to add more  tasks under that RITM, any idea about it?

 

Thank You in advance

1 ACCEPTED SOLUTION

My bad. Need to also set "request_item". Change the line setting response to following.

 

    response = requests.post(url, auth=(SERVICENOW_USER, SERVICENOW_PWD), headers=headers,
                             data="{\"parent\":\"" + task.get('rtim')
                                  + "\",\"priority\":\"" + task.get('priority')
                                  + "\",\"state\":\"" + task.get('state')
                                  + "\",\"short_description\":\"" + task.get('short_description')
                                  + "\",\"request_item\":\"" + task.get('rtim')
                                  + "\",\"assignment_group\":\"" + task.get('assignment_group') + "\"}")

Output

find_real_file.png

View solution in original post

10 REPLIES 10

It's necessary to replace the value of 'rtim' in the following statement with the actual sys_id of the rtim to add the task.

task = {'rtim': 'ab10cc9fdbef901083212a9a48961929',

yeah, i changed this value and other payload values as well, payload which i am passing is given below also attaching Screenshot here for reference.

task = {'parent': '324ca6a3dbde98585489fac2f396197d',
'priority': '4',
'state': '1',
'short_description': 'test task created by NANYADAV',
'assignment_group': '2b4357e7db41945092805c83f39619d9'
}

My bad. Need to also set "request_item". Change the line setting response to following.

 

    response = requests.post(url, auth=(SERVICENOW_USER, SERVICENOW_PWD), headers=headers,
                             data="{\"parent\":\"" + task.get('rtim')
                                  + "\",\"priority\":\"" + task.get('priority')
                                  + "\",\"state\":\"" + task.get('state')
                                  + "\",\"short_description\":\"" + task.get('short_description')
                                  + "\",\"request_item\":\"" + task.get('rtim')
                                  + "\",\"assignment_group\":\"" + task.get('assignment_group') + "\"}")

Output

find_real_file.png

yeah, now its working, thank you so much, it solved my crucial issue. 

 

Hi,

you should send the ritm sys_id like this

{'request_item': 'ritm sysId',

what error you are getting

Regards
Ankur

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