我的问题是-如何将搜索参数传递给方法。 我找不到要搜索的任何文档或样本。任何样本示例都对我有用。
源代码
String npTok = null;
String queryParam ="modifiedTime > '2012-06-04T12:00:00' and (mimeType
contains 'image/' )";
com.google.api.services.drive.Drive.Files.List qry = drive.files().list().setFields("files(id, name)").setQ(queryParam);
com.google.api.services.drive.model.FileList gLst = qry.execute();
for (com.google.api.services.drive.model.File gFl : gLst.getItems())
{
String id = gFl.getId();
System.out.println("ID==>"+id);
}
错误
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"location" : "fields",
"locationType" : "parameter",
"message" : "Invalid field selection name",
"reason" : "invalidParameter"
} ],
"message" : "Invalid field selection name"
}
谢谢大家
参考波纹管链接,您可以获得示例代码以及有关Google驱动器V3 Java api搜索的更多信息。
https://developers.google.com/drive/v3/web/search-parameters
错误消息反对的是fields
参数,而不是q
。 您的语法对于v3是正确的,因此我怀疑您的客户端库仍在使用v2。 尝试用items(id,title)
替换files(id,name)
items(id,title)
。 如果可行,则您使用的是旧版本的库。