I've followed the Drive API v3 docs to Download a Google Document. I am able to sucessfully download a spreadsheet in PDF format, as per the example, building the request as follows:
from googleapiclient.discovery import build
drive_service = build('drive', 'v3', credentials=creds)
SPREADSHEET_ID = 'mySpreadSheetID'
request = drive_service.files().export_media(fileId=SPREADSHEET_ID,
mimeType='application/pdf',
)
I wish to pass the custom params from this answer as part of the request, specifically to set gridlines=false
.
I found from the docs for googleapiclient.http.HttpRequest
that I can inspect the request further with:
request.to_json()
which gives me:
('{"uri": '
'"https://www.googleapis.com/drive/v3/files/mySpreadSheetID/export?mimeType=application%2Fpdf&alt=media", '
'"method": "GET", "body": null, "headers": {"accept": "*/*", '
'"accept-encoding": "gzip, deflate", "user-agent": "(gzip)", '
'"x-goog-api-client": "gdcl/1.7.11 gl-python/3.7.4"}, "methodId": '
'"drive.files.export", "resumable": null, "response_callbacks": [], '
'"_in_error_state": false, "body_size": 0, "resumable_uri": null, '
'"resumable_progress": 0}')```
I suspect &gridlines=false
needs to be appended to the uri
before the request is made, however I'm unsure how to modify this.
Am I on the right track, and if not, is there another way to pass these parameters from the Python library?