设置“发布到网络”在Google电子表格中使用Drive python API [英] Set "publish to web" in Google spreadsheet using Drive python API

查看:104
本文介绍了设置“发布到网络”在Google电子表格中使用Drive python API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图模拟使用Python版Google Drive API在Google文档中点击发布到网络 - >立即开始发布。基于对文档的模糊理解,我认为这应该起作用:

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.

我希望能够以编程方式创建立即可以访问的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()

这将返回一个修订对象并设置在文档上发布属性。

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

这篇关于设置“发布到网络”在Google电子表格中使用Drive python API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆