为什么即使包含可写属性(
Google Drive API v3 Comments
和 writableFieldRequired
),comment
也会抛出 anchor
错误?
function testComment() {
var doc = DocumentApp.getActiveDocument();
var token = ScriptApp.getOAuthToken();
var docId = doc.getId();
var urlDriveCommentsV3 = 'https://www.googleapis.com/drive/v3/files/' + docId + '/comments?fields=id';
var anchor = {
'r': 'head',
'a': [
{
'txt': {
'o': 1,
'l': 6
}
}
]
};
var commentv3 = {
'content': 'This is a test comment 01',
'anchor': anchor
};
var options = {
'method': 'post',
'headers': {
'Authorization': 'Bearer '+ token,
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
},
'payload': commentv3,
'muteHttpExceptions': true
};
var result = UrlFetchApp.fetch(urlDriveCommentsV3, options);
Logger.log(result);
};
{
"error": {
"code": 400,
"message": "At least one writable field must be specified in the resource body.",
"errors": [
{
"message": "At least one writable field must be specified in the resource body.",
"domain": "global",
"reason": "writableFieldRequired"
}
]
}
}
Drive API v3
Google Apps 脚本