一直在使用谷歌api客户端的网站,我想从用户的驱动器帐户获取一个文件夹列表,并在gapi
中的所有内容都正确设置,以提出请求。问题是我不理解q
请求对象的文档。
根据我的理解,我应该使用drive/files/list
端点,并传递选项来过滤掉所有非文件夹。
从我可以从文档中收集到的是我的请求看起来应该是这样的:
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));
但我继续得到这个错误:
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value",
"locationType": "parameter",
"location": "q"
}
],
"code": 400,
"message": "Invalid Value"
}
}
我试图将q
定义为'mimeType="application/vnd.google-apps.folder"'
和'mimeType=\'application/vnd.google-apps.folder\''
但我得到相同的error in q
结果。有人可以告诉我如何使用q
参数?我确信在google api中搜索非常重要。
适当的方法:
事实证明我实际上没有尝试过双引号,这最终是答案。
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));