Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Is it possible to create multiple incident records with the REST API?

bonsai
Mega Sage

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)

 

1 ACCEPTED SOLUTION

eumak
Tera Guru

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

Mark it as helpful or correct, If Applicable


Cheers..!

Happy Learning:)

Tushar

View solution in original post

3 REPLIES 3

eumak
Tera Guru

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

Mark it as helpful or correct, If Applicable


Cheers..!

Happy Learning:)

Tushar

Thank you for answering!
I was able to implement it!

Glad to hear:)

 

Cheers..!
Happy Learning:)
Tushar

Mark it as helpful or correct, If Applicable


Cheers..!

Happy Learning:)

Tushar