Find your content:

Search form

You are here

How to Insert/Update multiple records in a single REST API call?


We can use the REST API to perform DML operations. I want to know if there is a way that we can insert/update more than 1 record using a single REST API call.

Attribution to: sachin agarwal

Possible Suggestion/Solution #1

Surely yes you can .

All you need to do is refer the below code to get started,I assume its POST call and you are familiar with @HTTP POST annotations

Here is the sample code

List<Account> lstacc=new List<Account>();

    //Extracting the data from the JSON HTTP request object sent from iPad
    RestRequest req = RestContext.request;
    RestResponse res=RestContext.response;
    Blob body=req.requestBody;
    String jsonToParse=body.toString(); 
    lstacc=(List<Account>)JSON.deserialize(jsonToParse, List<Account>.class);
    update lstacc;

Also the following link from apex guide will help you

There is wonderful blog from Abhinav Gupta MVP on this that may help you as well

Attribution to: Mohith Shrivastava

Possible Suggestion/Solution #2

Found a post by @superfell - "You can't insert multiple rows in a single call in the rest api, you need to use the bulk api."

Attribution to: techtrekker

Possible Suggestion/Solution #3

Looks like there is an option coming in Summer `15

In Summer '15 there are new and changed resources available through the REST API.


The Batch resource lets you execute a sequence of independent subrequests. For example, you can update the name on an account and get the account’s field values in a single request.

"batchRequests" : [
    "method" : "PATCH",
    "url" : "v34.0/sobjects/account/001D000000K0fXOIAZ",
    "richInput" : {"Name" : "NewName"}
    "method" : "GET",
    "url" : "v34.0/sobjects/account/001D000000K0fXOIAZ"

The response contains the status codes of each subresponse and the responses themselves.

"hasErrors" : false,
"results" : [
    "statusCode" : 204,
    "result" : null
    "statusCode" : 200,
    "result" : { Account attributes }

Plus there is a pilot for the SObject Tree resource that:

lets you create multiple sObject trees that share a root record type. An sObject tree is a collection of nested, parent-child records with a single root record.

Knowledge Article Number: 000214070 - Summer `15 - REST API Updates

Attribution to: Daniel Ballinger
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content