【发布时间】:2023-03-16 01:03:01
【问题描述】:
我一直使用非常具体的约定来命名云端硬盘文件,以便于从应用中搜索它们。 v3 Drive API (files.list) 中的搜索功能在三周前一直在工作,但后来停止工作。
例如,使用以下文件,
“ABC-123 模板”、“ABC-123 gogo”、“ABC-123 bobo”
... 使我能够使用
通过 API 进行搜索name contains 'ABC-123'
此搜索应返回所有三个文件。相反,它不返回任何结果。请注意,Drive Web 界面中的相同查询是成功的,并且约定遵循documentation 中规定的规则。
这工作正常,但现在停止了。搜索 API 有变化吗?!我可以找到其他具有实现的文件,而不是那些使用命名约定的文件。
这是 NodeJS 中请求的完整代码 sn-p。
Google.prototype.findFiles = function(file_prefix, callback) {
var service = google.drive('v3');
service.files.list({
q: "name contains '" + file_prefix + "'",
fields: 'nextPageToken, files(id, name)',
spaces: 'drive',
corpus: 'domain',
auth: this.auth
}, function(err, response) {
if(err) {
console.log('Error : findFiles failed. ' + err);
callback(err);
} else {
callback(null,response.files);
}
});
};
【问题讨论】:
-
我发现当我使用 Google 的 API Explorer 时,这个请求确实有效。感觉就像我在控制台上的 Google 项目配置存在配置问题。
-
^^ 原来 不是 是这种情况,但它让我在下面得到了答案。
-
当您将
name contains 'ABC-123'输入developers.google.com/drive/v2/reference/files/list 的q 字段时,我得到error 400, invalid query
标签: google-drive-api