Reputation: 99
drive.files.list(
{
// pageSize: 10,
fields: "nextPageToken, files(id, name, mimeType, parents)"
},
(err, res) => {
if (err) return console.log("The API returned an error: " + err);
listToShow = res.data
const files = res.data.files;
if (files.length) {
console.log("Files:");
files.map((file) => {
console.log(`${file.name} (${file.id})`);
});
} else {
console.log("No files found.");
}
}
);
Here is excerpt of result looks like:
"files": [
{
"id": "1v922pMgws8pzuIsdJd8ziAJdTXJq237A",
"name": "January",
"mimeType": "application/vnd.google-apps.folder",
"parents": [
"1mjmkzpFUo_nsjgzOnA4lfi_b8bfJR2mP"
]
},
{
"id": "1_JLPz8CBvNJmNmyjvv70W5oRkuTAs0a4",
"name": "Bills",
"mimeType": "application/vnd.google-apps.folder",
"parents": [
"1EjaQDd4lmDZvdjAVMrDr2hZ78vBSuEFU"
]
}
]
I am using this for metadata my reference https://developers.google.com/drive/api/v3/reference/files
I am trying to get more fields displayed in my result like sharingUser, owners[]
I am modifying the line 4 of code as below :
fields: "nextPageToken, files(id, name, mimeType, parents , sharingUser, owners[])"
Error Log :Error: Invalid field selection nextPageToken, files(id, name, mimeType, parents , sharingUser, owners[] )
What is the syntax to get the result?
Upvotes: 0
Views: 859
Reputation: 201378
When your field value is modified, it becomes as follows.
fields: "nextPageToken, files(id, name, mimeType, parents , sharingUser, owners[])"
fields: "nextPageToken,files(id,name,mimeType,parents,sharingUser,owners)"
When you want to retrieve all fields, you can use the following fields.
fields: "nextPageToken,files,kind,incompleteSearch"
and
fields: "*"
*
can be used for the method of Files: list of Drive API v3. But for example, at the get method in Sheets API, all fields cannot be retrieved by *
. So please be careful this.Upvotes: 1