I have below piece of code to list out all available folders using Drive API's. But after 3000 folders it error out as '500 Internal Error'. How to find which folder and why this error is coming based on the NextPageToken?
Note: It was working properly in last week and from today we started seeing this issue.
Note: Even retry does not work. I have changed the MaxResults value to 1 but even though it fails.
FilesResource.ListRequest list = _DriveService.Files.List();
list.Q = "mimeType = 'application/vnd.google-apps.folder' and trashed = false";
list.MaxResults = 1000;
FileList folders = null;
do
{
folders = list.Fetch<FileList>();
foreach (File folder in folders.Items)
{
retColl.Add(folder.Id, folder);
}
list.PageToken = folders.NextPageToken;
} while (!string.IsNullOrEmpty(list.PageToken));