google-docs - 如何使用 Google Docs API 编辑 Google Docs 标题?
问题描述
我已经尝试过 Create、batchUpdate、从https://developers.google.com/docs/api/how-tos/overview获取。
即使在batchUpdate
我没有看到编辑选项title
。我用它来编辑文档的内容 - 插入/删除,但不是标题。
鉴于我有文档 ID,如何编辑文档标题?有没有办法使用 API 编辑文档标题?
解决方案
我相信你的目标如下。
- 您想修改 Google 文档的标题。
- 即,您要修改 Google Document 的文件名。
为此,这个答案怎么样?
为了修改 Google Document 的文件名,您可以使用 Drive API 中的“Files:update”方法来实现。遗憾的是,Google Docs API 不能用于修改 Google Document 的文件名。
端点:
PATCH https://www.googleapis.com/drive/v3/files/fileId
示例请求正文:
{"name":"updated title"}
示例卷曲:
curl --request PATCH \
'https://www.googleapis.com/drive/v3/files/{documentId}' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"name":"updated title"}' \
--compressed
参考:
添加:
当您想使用浏览器请求时,您可以使用此快速入门进行授权,并使用Files: update来修改标题。作为示例脚本,我将向您展示 Files:update for Javascript 方法的示例脚本,如下所示。请使用快速入门中的授权脚本。
示例脚本:
gapi.client.drive.files.update({
fileId: fileId,
resource: {name: "updated title"},
}).then((response) => {
console.log(response);
});
推荐阅读
- c# - 关闭主窗口时如何使用 DisplayAlert
- python - 使用 DATE 和特定时间过滤 pandas 数据框
- r - 尝试存储从函数估算的值失败
- oracle - plsql打印自定义对象
- azure - azure ad b2c mfa 无密码身份验证技术配置文件合并屏幕
- .net - LabView中使用.net设计用户界面,点击按钮时程序没有响应
- json - Flutter 无法加载资产 json
- javascript - 如何将数组转换为对象数组?
- google-apps-script - 如何发送带有数据输入选项的电子邮件?
- javascript - 查询。删除现有的处理程序并自己调用它们