- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2020 03:25 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2020 10:20 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2020 12:15 AM
you need to use REST API explorer for this
Specify the Request Item and other fields such as short description, assignment group etc
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2020 08:48 PM
Hi Ankur,
Actually i dont have REST API Explorer access so i am trying at my own level.
i asked Admin team to get this API url, they have access but they dont know how to do it.
if you know steps then let me know, ill ask them to do same from their end.
Thank You!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2020 12:58 AM
Following will add a task to rtim.
import requests
SERVICENOW_INSTANCE = '<ServiceNow instance>'
SERVICENOW_USER = '<username>'
SERVICENOW_PWD = '<password>'
def insert_new_task_2_rtim(task):
url = f'https://{SERVICENOW_INSTANCE}.service-now.com/api/now/table/sc_task'
headers = {"Content-Type": "application/json", "Accept": "application/json"}
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') + "\",\"assignment_group\":\"" + task.get('assignment_group') + "\"}")
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:', response.json())
exit()
data = response.json()
print(data)
if __name__ == '__main__':
task = {'rtim': 'ab10cc9fdbef901083212a9a48961929',
'priority': '4',
'state': '1',
'short_description': 'test task',
'assignment_group': '8a4dde73c6112278017a6a4baf547aa7'
}
insert_new_task_2_rtim(task)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2020 08:46 PM
I tried, this creates task but not associating with passed RITM. RITM field shows empty.
passed different variables information but same output i got.
any idea why this is happening, same thing i tried before that time it was creating Request, RITM and task for each api call.