How to pass the fields parameter into a google drive python API call
google-drive-api, python
Solution
API v2:
results = drive_service.files().list(fields='items(id,mimeType,title)', **body).execute()
you can easily figure out what the fields value should look like using API Explorer:
https://developers.google.com/apis-explorer/#p/drive/v2/drive.files.list
API v3:
results = drive_service.files().list(fields='files(id,mimeType,name)', **body).execute()
https://developers.google.com/apis-explorer/#p/drive/v3/drive.files.list
yes, the requests are automatically gzipped. You can turn on http traffic logging to confirm. see:
https://developers.google.com/api-client-library/python/guide/logging
Problem
I have: ``` results = drive_service.files().list(**body).execute() ``` where: ``` body = { 'q': query_string, 'maxResults': 1, } ``` To improve performance I would like to limit the fields returned as described here: https://developers.google.com/drive/performance#partial-response if i just add `'fields': 'id,items,title,mimeType'` to `body` i get an error. I'm not sure how to add that limitation? Somewhat related, does the python api automatically gzip the request?