Can I create multiple records in one POST using the REST API Explorer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2024 10:35 PM
I'm looking to create records with REST.
This is required for functional testing currently under development.
I'm looking for the ability to create records at the same time, something that can't be replicated with features like import.
I believe I can create a record using the REST API Explorer, but it seems I can only create one record.
Can I create multiple records?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2024 10:50 PM
Hi @bonsai ,
To create multiple records in ServiceNow using the REST API, use the batch API endpoint. I've provided some more information below, See if it helps:
Batch API Endpoint:
POST https://<instance_name>.service-now.com/api/now/v1/batch
Request Header:
{
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Basic <base64-encoded-credentials>"
}
Request Body Example:
{
"batch_request": [
{
"method": "POST",
"url": "/api/now/table/incident",
"body": {
"short_description": "Issue with email",
"priority": "2"
}
},
{
"method": "POST",
"url": "/api/now/table/incident",
"body": {
"short_description": "Cannot access VPN",
"priority": "1"
}
}
]
}
Try playing around with it.
Thanks,
Hope this helps.
If my response proves helpful please mark it helpful and accept it as solution to close this thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2024 11:03 PM
Hi @bonsai ,
Please have a look at the below:
You can also use importSetAPI to insert multiple records:
API Document for reference: POST API
Mark this as Helpful / Accept the Solution if this helps
Mark this as Helpful / Accept the Solution if this helps.