我相信你的目标如下。
对此,这个答案如何?
为了修改Google文档的文件名,您可以使用Drive API中的“文件:更新”方法来实现这一点。遗憾的是,Google文档API无法用于修改Google文档的文件名。
端点:
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
参考:
补充:
当你想使用浏览器请求时,你可以使用
this quickstart
授权和
Files: update
用于修改标题。作为示例脚本,我向您展示了Javascript的Files:update方法的示例脚本,如下所示。请使用来自的授权脚本
the quickstart
.
示例脚本:
gapi.client.drive.files.update({
fileId: fileId,
resource: {name: "updated title"},
}).then((response) => {
console.log(response);
});