pisarzp
pisarzp

Reputation: 677

500 error when trying to list files from Drive with query parameter

I'm trying to pull list of files from Google Drive using Python Api. Whenever I try to add parameter q to the files().list() I get error 500. Is there something I can do about it? When I don't add the q parameter I do see a lot of files in the response.

Initially I tried with scope https://www.googleapis.com/auth/drive, but different thread on SO suggested limit it to https://www.googleapis.com/auth/drive.readonly.metadata. Unfortunately this diddn't help.

I'm getting following error:

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 "">

Below is my python request for the record

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)

Upvotes: 0

Views: 244

Answers (1)

Cheryl Simon
Cheryl Simon

Reputation: 46844

Your search query doesn't look valid. See https://developers.google.com/drive/web/search-parameters for valid examples.

Upvotes: 1

Related Questions