尝试使用查询参数列出 Drive 中的文件时出现 500 错误
500 error when trying to list files from Drive with query parameter
我正在尝试使用 Python Api 从 Google 驱动器中提取文件列表。
每当我尝试将参数 q 添加到 files().list() 时,我都会收到错误 500。我可以做些什么吗?当我不添加 q 参数时,我确实在响应中看到了很多文件。
最初我尝试使用范围 https://www.googleapis.com/auth/drive, but different thread on SO suggested limit it to https://www.googleapis.com/auth/drive.readonly.metadata。不幸的是,这没有帮助。
我收到以下错误:
Traceback (most recent call last):
File "weekly_reporting.py", line 52, in <module>
main()
File "weekly_reporting.py", line 47, in main
connectToGoogleDrive()
File "weekly_reporting.py", line 38, in connectToGoogleDrive
file = drive_service.files().list(q="Google").execute()
File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.4.5-py2.7.egg/oauth2client/util.py", line 135, in positional_wrapper
File "/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.3.1-py2.7.egg/googleapiclient/http.py", line 723, in execute
googleapiclient.errors.HttpError: <HttpError 500 when requesting https://www.googleapis.com/drive/v2/files?q=Google&alt=json returned "">
以下是我的python备案要求
flow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE,redirect_uri=REDIRECT_URI)
authorize_url = flow.step1_get_authorize_url()
print 'Go to the following link in your browser: ' + authorize_url
code = raw_input('Enter verification code: ').strip()
credentials = flow.step2_exchange(code)
# Create an httplib2.Http object and authorize it with our credentials
http = httplib2.Http()
http = credentials.authorize(http)
drive_service = build('drive', 'v2', http=http)
file = drive_service.files().list(q="Google").execute()
pprint.pprint(file)
您的搜索查询看起来无效。有关有效示例,请参阅 https://developers.google.com/drive/web/search-parameters。
我正在尝试使用 Python Api 从 Google 驱动器中提取文件列表。 每当我尝试将参数 q 添加到 files().list() 时,我都会收到错误 500。我可以做些什么吗?当我不添加 q 参数时,我确实在响应中看到了很多文件。
最初我尝试使用范围 https://www.googleapis.com/auth/drive, but different thread on SO suggested limit it to https://www.googleapis.com/auth/drive.readonly.metadata。不幸的是,这没有帮助。
我收到以下错误:
Traceback (most recent call last):
File "weekly_reporting.py", line 52, in <module>
main()
File "weekly_reporting.py", line 47, in main
connectToGoogleDrive()
File "weekly_reporting.py", line 38, in connectToGoogleDrive
file = drive_service.files().list(q="Google").execute()
File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.4.5-py2.7.egg/oauth2client/util.py", line 135, in positional_wrapper
File "/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.3.1-py2.7.egg/googleapiclient/http.py", line 723, in execute
googleapiclient.errors.HttpError: <HttpError 500 when requesting https://www.googleapis.com/drive/v2/files?q=Google&alt=json returned "">
以下是我的python备案要求
flow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE,redirect_uri=REDIRECT_URI)
authorize_url = flow.step1_get_authorize_url()
print 'Go to the following link in your browser: ' + authorize_url
code = raw_input('Enter verification code: ').strip()
credentials = flow.step2_exchange(code)
# Create an httplib2.Http object and authorize it with our credentials
http = httplib2.Http()
http = credentials.authorize(http)
drive_service = build('drive', 'v2', http=http)
file = drive_service.files().list(q="Google").execute()
pprint.pprint(file)
您的搜索查询看起来无效。有关有效示例,请参阅 https://developers.google.com/drive/web/search-parameters。