Can I create multiple records in one POST using the REST API Explorer?

bonsai
Mega Sage

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?

2 REPLIES 2

HrishabhKumar
Kilo Sage

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.

 

SN_Learn
Kilo Patron
Kilo Patron

Hi @bonsai ,

 

Please have a look at the below:

POST multiple records 

 

You can also use importSetAPI to insert multiple records:

SN_Learn_0-1719208658991.png

 

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.