Been working with the google api client for websites, and I'm looking to get a list of folders from the user's drive account, and everything in gapi
is setup properly to make requests. The issue is that I don't understand the documentation of the q
request object.
from what I understand, I should be using the drive/files/list
endpoint, and passing options to filter out all the non-folders.
From what I can glean from the docs is that my request should look something like this:
gapi.client.drive.files.list({
q: 'mimeType=application/vnd.google-apps.folder',
pageSize: 25,
fields: 'nextPageToken, files(name, kind, parents)'
}).then(response => console.log(response))
.catch(err => console.error(err));
but I continue to get this error:
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value",
"locationType": "parameter",
"location": "q"
}
],
"code": 400,
"message": "Invalid Value"
}
}
I've tried to define q
as 'mimeType="application/vnd.google-apps.folder"'
and 'mimeType=\'application/vnd.google-apps.folder\''
But I get the same error in q
result. Could someone please show me how to use the q
parameter? I'm sure it's really important to searching in the google api.
Appropriate method:
It turns out I had not actually tried the double quoted version, which was eventually the answer.
gapi.client.drive.files.list({
q: 'mimeType="applicaton/vnd.google-apps.folder"',
pageSize: 25,
fields: 'nextPageToken, files(name, kind, parents)',
}).then(res => console.log(res)).catch(err => console.error(err));