Forum Discussion
Sharepoint Recycle Bin as Datasource
- 1 year ago
Hi pallavi_r
That is currently not possible with Power BI - not with any available SharePoint connectors. Check this out for the workaround on how to get the data:
- 1 year ago
Hi pallavi_r
I'm not sure if this meets your requirements, but I was able to query the list of files (but not content of files) in a SharePoint Online site's recycle bin with this:
let SiteURL = "https://YOUR_TENANT.sharepoint.com/sites/YOUR_SITE", SharePointRecycleBin = OData.Feed(SiteURL & "/_api/web/RecycleBin") in SharePointRecycleBinAppears to refresh successfully in the service with OAuth credentials.
- 1 year ago
Hi pallavi_r
Glad that this helped!
I did some testing at my end to locate files in the Second-Stage Recycle Bin (aka Site Collection Recycle Bin).
For my test site, it appears that if you use the above query with path
"/_api/site/RecycleBin"and filter on ItemState = 2, this corresponds to the Second-Stage Recycle Bin.
So the full query to get Second-Stage Recycle Bin that worked in my case is:
let SiteURL = "https://YOUR_TENANT.sharepoint.com/sites/YOUR_SITE", SharePointRecycleBin = OData.Feed(SiteURL & "/_api/site/RecycleBin"), #"ItemState 2" = Table.SelectRows(SharePointRecycleBin, each ([ItemState] = 2)) in #"ItemState 2"This worked for me at least. I think technically the Second-Stage Recycle Bin exists per site collection rather than per site (in my case there is one site per collection anyway), so the query may vary when multiple sites are in one collection, but I'm not an expert on this aspect of SharePoint Online myself 😉
Does something like this work for you?
Hi pallavi_r
Glad that this helped!
I did some testing at my end to locate files in the Second-Stage Recycle Bin (aka Site Collection Recycle Bin).
For my test site, it appears that if you use the above query with path
"/_api/site/RecycleBin"
and filter on ItemState = 2, this corresponds to the Second-Stage Recycle Bin.
So the full query to get Second-Stage Recycle Bin that worked in my case is:
let
SiteURL = "https://YOUR_TENANT.sharepoint.com/sites/YOUR_SITE",
SharePointRecycleBin = OData.Feed(SiteURL & "/_api/site/RecycleBin"),
#"ItemState 2" = Table.SelectRows(SharePointRecycleBin, each ([ItemState] = 2))
in
#"ItemState 2"
This worked for me at least. I think technically the Second-Stage Recycle Bin exists per site collection rather than per site (in my case there is one site per collection anyway), so the query may vary when multiple sites are in one collection, but I'm not an expert on this aspect of SharePoint Online myself 😉
Does something like this work for you?
Hi OwenAuger ,
Thank you, that's amazing. You have solved my problem. How did you find this?
Yes with the itemstate = 2 filter, I could get into second stage recycle bin.
One thing I noticed, when I use the below code, I get both first stage and second stage recycle bin.
"/_api/site/RecycleBin"
So now I can get a list where both first stage and 2nd stage deleted items are there. Did not find any attribute to distinguish.
And I can get the list where second stage deleted items are there.
I would also need the deleted items only from first stage recycle bin. How to get that?
Thank you so much. Appreciate a lot for this great help.
Thanks,
Pallavi
- OwenAuger1 year agoSuper User
You're welcome pallavi_r .
To be honest, I found this through trial and error, and piecing together info from some Microsoft documentation pages (e.g. here).
Just to clarify, it appears that ItemState represents the "recycle bin stage".
So if you just use this query, you can return both 1st and 2nd stage recycle bins and distinguish them with the ItemState column.
At least this is how it appears for my test site:
let SiteURL = "https://YOUR_TENANT.sharepoint.com/sites/YOUR_SITE", SharePointRecycleBin = OData.Feed(SiteURL & "/_api/site/RecycleBin") in SharePointRecycleBin