問題描述
我正在嘗試使用 Python 版本的 Google Drive API 在 Google 文檔中模擬單擊發(fā)布到網絡"->立即開始發(fā)布".根據我對文檔的模糊理解,我相信這應該可行:
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.
我希望能夠以編程方式創(chuàng)建一個可供全世界立即訪問的 Google 電子表格.
I'd like to be able to programmatically create a Google spreadsheet that is immediately world-accessible.
推薦答案
原來上面代碼片段返回的響應對象需要調用execute()
:
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()
這會返回一個修訂對象并設置文檔的發(fā)布屬性.
This returns a revision object and sets the publish properties on the document.
這篇關于設置“發(fā)布到網絡"在 Google 電子表格中使用 Drive python API的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!