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?
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
try
body = {
'q': query_string,
'maxResults': 1,
'fields': 'items/id, items/title, items/mimeType',
}
or
body = {
'q': query_string,
'fields': 'items(id,title,mimeType),nextPageToken', # if you need to get full result
}
I had similar problem, the problem was in api version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With