I'm developing a web app in MVC .Net (VS 2019 + Google Drive Api v3). We are using a service account consuming a shared folder from a simple google account. We need to create a folder for each task of our students. We have 2000 students and they have average of 10 tasks per month. So We will have a lot of folders in our Google drive. Because of that I decided to make some tests with a console application and realized some errors after creating multiple folders. Someone know if Google Drive Api has a kind of limit on creation multiple folders? Below is a console application to prove that with a print image.
namespace DriveQuickstart
{
class Program
{
static void Main(string[] args)
{
string[] Scopes = { DriveService.Scope.DriveReadonly, DriveService.Scope.DriveFile };
ServiceAccountCredential credential;
using (var stream =
new FileStream("key.json", FileMode.Open, FileAccess.Read))
{
credential = GoogleCredential.FromStream(stream)
.CreateScoped(Scopes)
.UnderlyingCredential as ServiceAccountCredential;
}
// Create Drive API service.
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Test App",
});
Google.Apis.Drive.v3.Data.File body = new Google.Apis.Drive.v3.Data.File();
for (int i = 0; i < 50; i++)
{
body.Name = "Test_" + Guid.NewGuid().ToString();
body.Description = "Created by me!";
body.MimeType = "application/vnd.google-apps.folder";
body.Parents = new List<string> { "1hLsDTub8bhlVS2ax34P8wGx5RsD0n8MA" };
try
{
service.Files.Create(body).Execute();
Console.WriteLine("Folder " + (i+1).ToString() + " created.");
}
catch (Exception e)
{
Console.WriteLine("Error = " + e.InnerException.Message);
}
}
}
}
}
The inner exception Error: "Unable to read data from transport connection. It was forced to cancel by remote server".