March 18, 2016

Deleted List item through REST API is not moving to Recycle Bin

To delete SharePoint list item, we can make use of REST API while customizing OOTB Delete item functionality in SharePoint list. To delete an item through REST API, we generally make use of following REST URL:
         
http://site_url/_api/web/lists(list_Id)/items(item_id)


Now, this will delete the specified list item permanently rather than moving it to Recycle bin. So, how could we move a List Item to Recycle bin using REST API same as OOTB Delete functionality?

We just need to append recycle() function to above REST URL. So, complete URL will be:

http://site_url/_api/web/lists(list_id)/items(item_id)/recycle()


Important Note: To move an item to Recycle bin, "Recycle bin" must be ON. You can turn it On or Off from Central administration. Below are the steps to configure Recycle bin:
  1. Open SharePoint Central Administration Site. Click Application Management.
  2. On Application Management page, Click Manage Web Applications.
  3. Click/Select the Web application for which you want to configure Recycle Bin. The ribbon becomes active.
  4. In ribbon, Click the General Settings.
  5. Under Recycle bin Section on General Settings page:
  6. Set the Recycle Bin for the Web application to be On or Off.
  7. By default, Recycle Bin is Turned On.
If you have any questions you can reach out our SharePoint Consulting team here.

No comments:

Post a Comment