9
votes

I'm trying to simulate clicking "publish to web" -> "start publishing now" in Google docs using the Python version of the Google Drive API. 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 appears to have no effect on my document.

I'd like to be able to programmatically create a Google spreadsheet that is immediately world-accessible.

1
This should be right. Do you get a valid revision object in return? - Ali Afshar
I didn't, I got back an HTTP Response object. However, your helpful comment helped me determine the solution, below... - David Eads

1 Answers

6
votes

Turns out the response object that's returned by the code snippet above needs to call execute():

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

This returns a revision object and sets the publish properties on the document.