Reputation: 105
I have a NodeJS app to read files in my google drive, source code like below:
var d = google.drive({ version: "v2", auth: oauth2Client });
var drive = d.drives.get({ driveId: "my-drive" });
need to have driveId as one of parameters, how to get it? besides, it's not shared drive, just my personal drive, I used drive name (my-drive) which is obvious wrong, URL and error message as below:
url: 'https://www.googleapis.com/drive/v2/drives/my-drive',
GaxiosError: Shared drive not found: my-drive
Upvotes: 0
Views: 2588
Reputation: 1343
Checking that you are trying to call your "My Drive" id however there is no API call to retrieve this information as it's not a folder per se, instead you can as well call the parent folders that are saved in your personal Drive, you can use a List that will return the parent folder ID about the file ID you are trying to work on.
The Drive.get method you are referring to only works for shared drive only as noted in the documentation:
Gets a shared drive's metadata by ID.
In this case you won't be able to use this API call if you are not trying to retrieve data from a Shared Drive itself.
Upvotes: 1
Reputation: 201603
I believe your goal is as follows.
In this case, I thought that the method of "Files: get" can be used. When this is reflected in your script, it becomes as follows.
var d = google.drive({ version: "v2", auth: oauth2Client });
var drive = await d.files.get({ fileId: "root" });
var id = drive.data.id;
console.log(id);
var drive = d.drives.get({ driveId: "my-drive" });
, drive
is Promise. Please be careful this.Upvotes: 4