Install "publish on the web" in a Google spreadsheet using the python API on disk

I am trying to simulate clicking "publish on the Internet" β†’ "start publishing now" in Google docs using the Google Drive API version in Python. Based on my vague understanding of the documentation, I believe this should work:

service.revisions().update(fileId = newfile['id'], revisionId='head', body={'published':True, 'publishAuto': True}) 

However, this does not seem to affect my document.

I would like to be able to programmatically create a Google spreadsheet that is immediately available to the whole world.

+8
python google-drive-sdk
source share
1 answer

Turns off the response object returned by the code fragment above, you need to call execute() :

 service.revisions().update(fileId = newfile['id'], revisionId='head', body={'published':True, 'publishAuto': True}).execute() 

This returns the revision object and sets the publication properties in the document.

+5
source share

All Articles