I believe your goal as follows.
- You want to modify the title of Google Document.
- Namely, you want to modify the filename of Google Document.
For this, how about this answer?
In order to modify the filename of Google Document, you can achieve this using the method of "Files: update" in Drive API. Unfortunately, Google Docs API cannot be used for modifying the filename of Google Document.
Endpoint:
PATCH https://www.googleapis.com/drive/v3/files/fileId
Sample request body:
{"name":"updated title"}
Sample curl:
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
Reference:
Added:
When you want to request using the browser, you can use 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.
Sample script:
gapi.client.drive.files.update({
fileId: fileId,
resource: {name: "updated title"},
}).then((response) => {
console.log(response);
});