Delete root site List Items using SharePoint 2013 REST API

Hi All,
Here is my code snippet, i am passing the item IDs in an array. below code is working to delete parent site(root site) list items using the REST API

function deleteiteminListAllDocs(itemIDarr)
 {

for(var j=0; j<itemIDarr.length;j++)
{
var itemID=itemIDarr[j];
console.log(itemID);
$.ajax
    ({
      // url: _spPageContextInfo.siteAbsoluteUrl + "/_api/site/rootweb/lists/GetByTitle('ProductInfo')/getitembyid('"+itemID+"')",
      url: _spPageContextInfo.webServerRelativeUrl+ "/_api/site/rootweb/lists/GetByTitle('ProductInfo')/items('"+itemID+"')",
      type: "DELETE",
       headers:
       {
           "accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "If-Match": "*",
             "X-HTTP-Method": "DELETE"
       },
     
        success: function(data)
       {
          //retriveListItem();
               console.log("SUcess");
       },
       error: function(error)
       {
       console.log("error in deleteiteminListAllDocs");
          // $("#ResultDiv").empty().text(data.responseJSON.error);
       }
   });
    }
 }

Comments

Popular posts from this blog

SharePoint 2013 REST API CRUD Operations

Add List Item Attachments to Task Form using Nintex Workflow and Forms

SharePoint ULS log viewer tool comparison and verdict