- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 10:52 PM
I'm currently writing a program in Python that creates a record in an instance.
It is possible to create a record for each case with the REST API, but it takes 1 second for each case.
Is it possible to create multiple records with a single REST command?
I don't know how to use REST API Explorer, so I specify the table name to get the basic code, process the contents and use it.
One record can be created with the following command.
I am wondering if it is possible to create multiple records with one command instead of creating multiple records by iterative processing.
#Need to install requests package for python
#easy_install requests
import requests
# Set the request parameters
url = 'https://dev~~~.service-now.com/api/now/table/incident'
# Eg. User name="admin", Password="admin" for this code sample.
user = 'admin'
pwd = 'admin'
# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}
record = f'{{"caller_id":"admin","short_description":"Test_Record2022"}}'
record = record.encode('utf-8')
# Do the HTTP request
response = requests.post(url, auth=(user, pwd), headers=headers ,data= record)
# Check for HTTP codes other than 200
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
exit()
# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 10:55 PM
Hello ,
Hope the below tutorial will help you to achieve the requirement.
https://www.youtube.com/watch?v=eB6CeA8RCig
Mark it helpful or correct, If Applicable
Cheers..!
Happy Learning:)
Tushar
Cheers..!

Happy Learning:)

Tushar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 10:55 PM
Hello ,
Hope the below tutorial will help you to achieve the requirement.
https://www.youtube.com/watch?v=eB6CeA8RCig
Mark it helpful or correct, If Applicable
Cheers..!
Happy Learning:)
Tushar
Cheers..!

Happy Learning:)

Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2022 10:49 PM
Thank you for answering!
I was able to implement it!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2022 10:57 PM
Glad to hear:)
Cheers..!
Happy Learning:)
Tushar
Cheers..!

Happy Learning:)

Tushar