Google.Apis.Requests.RequestErrorFile not found: . [404]Errors [ Message[File not found: .] Location[fileId - parameter] Reason[notFound] Domain[global]]
public Google.Apis.Drive.v3.Data.File CreateSheet() { string[] scopes = new string[] { DriveService.Scope.Drive, DriveService.Scope.DriveFile,}; var clientId = "123456337-wajklowlksflmxiowerasjdflsl.apps.googleusercontent.com"; // From https://console.developers.google.com var clientSecret = "kkslfdkiwowol_ssdwerss"; // From https://console.developers.google.com // here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData% var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret },scopes, Environment.UserName,CancellationToken.None,new FileDataStore("MyAppsToken")).Result; //Once consent is recieved, your token will be stored locally on the AppData directory, so that next time you wont be prompted for consent. DriveService _service = new DriveService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "MyAppName", }); var _parent = "";//ID of folder if you want to create spreadsheet in specific folder var filename = "helloworld"; var fileMetadata = new Google.Apis.Drive.v3.Data.File() { Name = filename, MimeType = "application/vnd.google-apps.spreadsheet", //TeamDriveId = teamDriveID, // IF you want to add to specific team drive }; FilesResource.CreateRequest request = _service.Files.Create(fileMetadata); request.SupportsTeamDrives = true; fileMetadata.Parents = new List<string> { _parent }; // Parent folder id or TeamDriveID request.Fields = "id"; System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }; var file = request.Execute(); MessageBox.Show("File ID: " + file.Id); return file; }
clientSecret
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)