Reputation: 1145
I'm looking for a way to retrieve the meta for a deleted item(file/folder). I'm able to get change logs indicating that a certain action has been performed on an Item, and I've been able to retrieve the Item itself as well if it hasn't been deleted.
The problem arises when this item gets deleted. In that case, I only know the ID of the Item and when I query the Item itself, I get a 404 (saying object has been deleted).
Recently, I read the following posts
It says a deleted item goes to user's recycle bin where it can be restored or deleted permanently. If deleted from recycle bin it goes to Site Collection Recycle Bin, where an Admin can restore or delete it permanently. So, I'm now looking for a way to access the Recycle Bin for a user and also the Site collection's recycle bin through the REST API.
Though I'm aware of the Recycle Bin endpoints mentioned here but they don't work for me as I keep getting an empty array even though I have a couple files/folders present in the recycle bin(user's recycle bin). I might be missing some configuration/setting?
I have 2 goals;
Both of these through the REST API.
Much appreciated!
Upvotes: 3
Views: 6492
Reputation: 59358
Recycle Bin resource endpoint URI:
http://<sitecollection>/<site>/_api/web/RecycleBin(recyclebinitemid)
Recycle Bin resource exposes SP.RecycleBinItem.itemType property that returns the type of the Recycle Bin item.
Examples
The following query demonstrates how return File
items:
http://<onedrive for business url>/_api/web/RecycleBin?$filter=(ItemType eq 1)
and the the following one how to return Folder
items:
http://<onedrive for business url>/_api/web/RecycleBin?$filter=(ItemType eq 5)
,where token <onedrive for business url>
for OneDrive For Business site has the following format:
https://tenant-my.sharepoint.com/personal/username_tenant_onmicrosoft_com
Upvotes: 3
Reputation: 1658
Does
http://<sitecollection>/<site>/_api/web/RecycleBin(recyclebinitemid)
work? I grabbed the structure from: SP.RecycleBinItem.restore Method (sp.js).
Upvotes: 1