如何使用 Google 文档 API 编辑 Google 文档标题?
How to Edit Google Docs title with Google Docs API?
我已尝试创建、批量更新、从 https://developers.google.com/docs/api/how-tos/overview 获取。
即使在 batchUpdate
中,我也看不到编辑 title
的选项。我用它来编辑文档的内容 - insert/delete,但不是标题。
如果我有文档 ID,如何编辑文档标题?
有什么方法可以使用 API 编辑文档标题吗?
我相信你的目标如下。
- 您想修改 Google 文档的标题。
- 即您要修改Google个文档的文件名。
为此,这个答案怎么样?
要修改Google文件的文件名,可以使用DriveAPI中"Files: update"的方法实现。不幸的是,Google Docs API 不能用于修改 Google Document.
的文件名
端点:
PATCH https://www.googleapis.com/drive/v3/files/fileId
样品请求body:
{"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
参考:
已添加:
当你想使用浏览器请求时,可以使用this quickstart for authorization and Files: update for modifying the title. As a sample script, I show you the sample script of the method of Files: update for Javascript as follows. Please use the authorization script from the quickstart。
示例脚本:
gapi.client.drive.files.update({
fileId: fileId,
resource: {name: "updated title"},
}).then((response) => {
console.log(response);
});
我已尝试创建、批量更新、从 https://developers.google.com/docs/api/how-tos/overview 获取。
即使在 batchUpdate
中,我也看不到编辑 title
的选项。我用它来编辑文档的内容 - insert/delete,但不是标题。
如果我有文档 ID,如何编辑文档标题? 有什么方法可以使用 API 编辑文档标题吗?
我相信你的目标如下。
- 您想修改 Google 文档的标题。
- 即您要修改Google个文档的文件名。
为此,这个答案怎么样?
要修改Google文件的文件名,可以使用DriveAPI中"Files: update"的方法实现。不幸的是,Google Docs API 不能用于修改 Google Document.
的文件名端点:
PATCH https://www.googleapis.com/drive/v3/files/fileId
样品请求body:
{"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
参考:
已添加:
当你想使用浏览器请求时,可以使用this quickstart for authorization and Files: update for modifying the title. As a sample script, I show you the sample script of the method of Files: update for Javascript as follows. Please use the authorization script from the quickstart。
示例脚本:
gapi.client.drive.files.update({
fileId: fileId,
resource: {name: "updated title"},
}).then((response) => {
console.log(response);
});