Google api 尝试使用Python';按GAPI驱动器v3中的文件id进行查询时出错;s图书馆
我使用service.files().list()并提供一个查询字符串来检索与给定列表中的ID匹配的文件。但是调用service.files.list会出错,GAPI返回的错误代码为400。我正在使用使用访问令牌创建的服务对象 我得到以下信息:Google api 尝试使用Python';按GAPI驱动器v3中的文件id进行查询时出错;s图书馆,google-api,google-drive-api,google-oauth,google-api-python-client,Google Api,Google Drive Api,Google Oauth,Google Api Python Client,我使用service.files().list()并提供一个查询字符串来检索与给定列表中的ID匹配的文件。但是调用service.files.list会出错,GAPI返回的错误代码为400。我正在使用使用访问令牌创建的服务对象 我得到以下信息: raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.go
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/drive/v3/files?pageSize=50&fields=%2A&q=id+contains+%271234%27&spaces=drive&alt=json returned "Invalid Value". Details: "Invalid Value">
您似乎正在尝试搜索
id contains
如果你查看文档
您将发现Id不是可搜索的字段
例如,尝试类似于name contains car
的方法
# Create file query string
queryStr = ""
for i in range(len(fileIds)):
queryStr += f"id='{fileIds[i]}'"
if i != len(fileIds) - 1:
queryStr += " or "
# Build files array
results = service.files().list(
pageSize=50,
fields="*",
q=queryStr,
spaces="drive"
).execute()
print(results.get("files", [0])[0])