0

I have following C# code and I have around 700k items in SecondStage RecycleBin. Any help would really appreciable.

using System.Diagnostics;
using Microsoft.Extensions.Logging;
using Microsoft.SharePoint.Client;
using PnP.Framework;

internal class Program
{
    private const string clientId = "<MyClientId>";

    private static async Task Main(string[] args)
    {
        var connection = AuthenticationManager.CreateWithInteractiveLogin(clientId, (url, port) =>
        {
            var psi = new ProcessStartInfo
            {
                FileName = url,
                UseShellExecute = true
            };
            Process.Start(psi);
        });
        var clientContext = await connection.GetContextAsync("https://<MyTenant>.sharepoint.com/personal/<MyAdminUser>/");
        var items = clientContext.Site.GetRecycleBinItems(null,
            1, false,
            RecycleBinOrderBy.DefaultOrderBy, RecycleBinItemState.SecondStageRecycleBin);

        clientContext.Load(items);
        await clientContext.ExecuteQueryRetryAsync();

        var item = items.First();
        item.Restore();

        await clientContext.ExecuteQueryAsync(); //Here the error is thrown
    }
}

enter image description here

Kishan
  • 73
  • 9

0 Answers0