How do you use Microsoft Graph API v5.7 in .NET to get RecycleBin items from Sharepoint

Simon Zhao 0 Reputation points
2025-03-25T22:43:07.39+00:00

Hi,

I'm using the latest Microsoft.Graph library in my .NET project with my SharePoint site. I wanted to create a endpoint to retrieve the items from the recycle bin, but found the following code obsolete because ".RecycleBin" is removed.

var deletedItems = await_graphClient
	.Drives[_driveId]
	.RecycleBin
	.GetAsync();

Then I saw this documentation about the recycle bin items.
https://learn.microsoft.com/en-us/graph/api/recyclebin-list-items?view=graph-rest-1.0&tabs=csharp

However, the examples in the website above has http call like this:

GET https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com,48f1898f-77d9-4a1b-bddc-1f49bb6dc134,7206fc09-e4af-48b3-8730-ed7321396d7a/recycleBin/items

While the C# code to get the items actually goes from the File Storage

// Code snippets are only available for the latest version. Current version is 5.x

var result = await graphClient.Storage.FileStorage.Containers["{fileStorageContainer-id}"].RecycleBin.Items.GetAsync();

What's even more confusing is that "fileStorageContainer-id" from the above example is not even defined. I have tried so many ways now trying to get the deleted items from my SharePoint site, but none of them worked. Please help me on the code of how to get the items from the recycle bin.

Thanks,
Simon

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,502 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 46,326 Reputation points
    2025-03-26T10:31:46.1366667+00:00

    Hi @Simon Zhao

    Based on my testing, this API does not appear to fully support the 1.0 endpoints yet, but it does work in beta.

    References: https://learn.microsoft.com/en-us/graph/api/recyclebin-list-items?view=graph-rest-beta&tabs=csharp#request.

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.