I'm looking to bulk create items to decrease the amount of calls being made in my application. In this instance, I'm working on a calendar control that has different needs than what SharePoint OOTB provides (or allows you to modify). That said, if a user selects several days and wants to create list items for those days, it makes no sense to make separate calls per item.

However, I can't figure out the correct way to format the JSON object to send out. My call is returning the following in data.body: {\"error\":{\"code\":\"-1, Microsoft.SharePoint.Client.InvalidClientQueryException\",\"message\":{\"lang\":\"en-US\",\"value\":\"A node of type 'StartArray' was read from the JSON reader when trying to read the start of an entry. A 'StartObject' node was expected.\"}}}"

That error is true -- I'm pushing SharePoint objects and trying to send those out. Here is my code:

for (var i = 0; i <= diffDays; i++) {
        __metadata: { "type": "SP.Data.TestListItem" },
        OData__x0066_x20: userName(),
        qnlu: startDate.addDays(i),
        OData__x006e_ot5: status

    url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('" + LIST_NAME + "')/items?@target='" + hostweburl + "'",
    method: "POST",
    body: JSON.stringify(items),
    headers: {
        "Accept": "application/json; odata=verbose",
        "content-type": "application/json; odata=verbose",
        "X-RequestDigest": $("#__REQUESTDIGEST").val()
    success: onAddEventSuccess,
    error: onoDataCallFailure

And here is the JSON object I'm trying to POST (taken from Visual Studio debugging): [{\"__metadata\":{\"type\":\"SP.Data.TestListItem\"},\"OData__x0066_x20\":\"user\",\"qnlu\":\"2013-07-24T04:00:00.000Z\",\"OData__x006e_ot5\":\"test\"},{\"__metadata\":{\"type\":\"SP.Data.TestListItem\"},\"OData__x0066_x20\":\"user\",\"qnlu\":\"2013-07-24T04:00:00.000Z\",\"OData__x006e_ot5\":\"test\"},{\"__metadata\":{\"type\":\"SP.Data.TestListItem\"},\"OData__x0066_x20\":\"user\",\"qnlu\":\"2013-07-24T04:00:00.000Z\",\"OData__x006e_ot5\":\"test\"}]

Any help is appreciated.

3 Answers 3


Unfortunately, the REST API does not provide a way to batch items (yet). However, you can batch add items using the JavaScript Client Object Model. Here is a sample code:

var itemArray = [];

function createListItems() {

    var clientContext = SP.ClientContext.get_current();
    var oList = clientContext.get_web().get_lists().getByTitle('TestList');
    for(var i = 0; i< 5; i++){
        var itemCreateInfo = new SP.ListItemCreationInformation();
        var oListItem = oList.addItem(itemCreateInfo);  
        oListItem.set_item('Title', 'My New Item!' + i);  
        itemArray[i] = oListItem;
    clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);

function onQuerySucceeded() {

    alert('Items created');

function onQueryFailed(sender, args) {

    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());



REST API supports batching now:



  • Thanks for this. What I really like about the REST API is that I get a collection of any added items back. Is there anyway to get that using JSOM? Also, any links to any decent documentation would be helpful. Everything on MSDN that I've found so far is extremely basic.
    – EHorodyski
    Commented Jul 15, 2013 at 19:13
  • Yes you do indeed get back the collection. You can access it using the itemArray. See the updated code. Also here is a MSDN link which I have found to be pretty useful for the JSOM docs: msdn.microsoft.com/en-us/library/hh185015(v=office.14).aspx Commented Jul 15, 2013 at 19:45
  • That isn't working for me. Where are you getting that code from? Should I be passing itemArray into onQuerySucceeded()? itemArray is undefined for me. Is Function.createDelegate() essential to getting that portion to work?
    – EHorodyski
    Commented Jul 15, 2013 at 20:05
  • Also, the page you posted is for SharePoint 2010.
    – EHorodyski
    Commented Jul 15, 2013 at 20:31
  • The code works as is for me. Are you sure you are defining itemArray outside the function? Maybe you can update your question with your code. Function.createDelegate() is not necessary for the code to run. Also, the link works for SP2013 too. The basics of the JSOM are same for SP2010 and SP2013 Commented Jul 15, 2013 at 21:40

Batching is now supported in REST O365 only. You can check out a javascript library on GitHub that batches these for you using the new capabilities.


  • Will there be any updates for on-prem in the future?
    – Jordan
    Commented Jan 20, 2015 at 15:04
  • That looks promising. What about on-premise support? Commented Jan 20, 2015 at 15:15
  • What is the max limit of actions per batch?
    – Yayati
    Commented Jan 15, 2021 at 11:02
    var listName = "AJAX";
    var itemType = GetItemTypeForListName(listName);

    function CreateListItem( ) {
     var title = document.getElementById('title').value;            
     var firstname = document.getElementById('firstname').value;   
     var lastname = document.getElementById('lastname').value;   

     var item = [{
           "__metadata": { "type": "SP.Data.AJAXListItem"  },
           "Title": "MISS",
           "FirstName": "Rudrani",
           "LastName": "Patil"                     
           "__metadata": { "type": "SP.Data.AJAXListItem"  },
           "Title": "Miss",
           "FirstName": "Rudra",
           "LastName": "Patil"                   


           "__metadata": { "type": "SP.Data.AJAXListItem"  },
           "Title": "MR",
           "FirstName": "Sumedh",
           "LastName": "MUDgalkar"                  


        for ( var itemindex = 0 ; itemindex < item.length ; itemindex ++)
         var employee = item[itemindex];

          url:  _spPageContextInfo.webAbsoluteUrl  + "/_api/web/lists/getbytitle('" + listName + "')/items",
          type: "POST",
          contentType: "application/json;odata=verbose",
          data: JSON.stringify(employee),
          headers: {
               "Accept": "application/json;odata=verbose",
               "X-RequestDigest": $("#__REQUESTDIGEST").val()
          success: function (data) {
          error: function (data) {

function GetItemTypeForListName (name)
           return "SP.Data." + name.charAt(0).toUpperCase() + name.split(" ").join("").slice(1) + "ListItem";


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.