Delete an item without skipping the Recycle Bin SharePoint 2013 REST

I learned this the hard way but using this code completely skips the recycle bin so once the item is deleted it cant easily be restored

oListItem.deleteObject();

The code below will send the item to the recycle bin.

function deleteListItem(listItemId) {
      $.ajax({ 
        type: "POST", 
        url: siteURL + `/_api/web/lists/getByTitle('Name Of My List')/items(${listItemId})/recycle()`, 
        headers: { 
            "accept": "application/json; odata=verbose", 
            "IF-MATCH": "*", 
            "X-RequestDigest": $("#_REQUESTDIGEST").val(),
        }, 
        success: function(data){ 
            console.log(data)
            alert("Item is deleted!"); 
        }, 
        error: function(error){ 
            alert("Error"); console.log(error); 
        } 
       });
  }

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top