简体   繁体   中英

How to get Folder ID while creating a new folder in Google Drive using API

I am trying to create a subfolder in google drive....I have created the main folder using API...Studying the Drive Api documentation I learned that to create a subfolder I need to specify the Main folder ID..But I couldn't find a way to get folder ID...

My question is , how to get Folder ID while creating a new folder in Google Drive using API

When you insert a file or create a directory you use Files: insert If successful, this method returns a Files resource in the response body.

If you check the return of your insert you will find id which is the id of the file or directory that you just created. You can then use this as the parent for your new directory.

Code directly from the documentation:

FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, mimeType);
request.Upload();
File file = request.ResponseBody;    
Console.WriteLine("File ID: " + file.Id);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM