Google Drive API v3 权限 sendNotificationEmail: False - 不工作
Google Drive API v3 Permissions sendNotificationEmail: False -Not Working
我正在利用 Google 驱动器 API v3 的权限端点调用将 reader 和编写器状态分配给共享 google 应用程序脚本中的文件夹驾驶。主要目标是在与用户共享权限时不发送通知电子邮件。我在请求正文中包含了参数 'sendNotificationEmail: false',但是仍在发送电子邮件通知用户。我正在使用的代码片段如下。我是否在请求的错误部分包含了 'sendNotificationEmail' 参数?
if (currTabName == "Testing" && curRange.getColumn() == 2){
for (var i = row; i < (row+rows); i++) {
var Email = currSS.getRange(i,2,1,1).getValue();
try{
var url = 'https://www.googleapis.com/drive/v3/files/FileID/permissions';
var data = {
'role': 'writer',
'type': 'user',
'sendNotificationEmail': false,
'emailAddress': Email,
'supportsAllDrives': true,
}
var options = {
'method' : 'POST',
'contentType': 'application/json',
'headers' : { Authorization: 'Bearer ' + 'yourAccessToken' },
'payload' : JSON.stringify(data) // Convert JavaScript object to JSON string
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response);
}
catch(err) {
Logger.log(err.message);
在Permissions: create of Drive API的方法中,查询参数中需要包含sendNotificationEmail
和supportsAllDrives
。我认为这就是你的问题的原因。那么下面的修改呢?
发件人:
var url = 'https://www.googleapis.com/drive/v3/files/folderthatstatusisgrantedfor/permissions';
var data = {
'role': 'writer',
'type': 'user',
'sendNotificationEmail': false,
'emailAddress': Email,
'supportsAllDrives': true,
}
var options = {
'method' : 'POST',
'contentType': 'application/json',
'headers' : { Authorization: 'Bearer ' + 'yourAccessToken' },
'payload' : JSON.stringify(data) // Convert JavaScript object to JSON string
};
var response = UrlFetchApp.fetch(url, options);
收件人:
var folderId = "###"; // Please set the folder ID.
var url = `https://www.googleapis.com/drive/v3/files/${folderId}/permissions`;
url += "?sendNotificationEmail=false&supportsAllDrives=true";
var data = {
'role': 'writer',
'type': 'user',
'emailAddress': Email,
}
var options = {
'method': 'POST',
'contentType': 'application/json',
'headers': { Authorization: 'Bearer ' + 'yourAccessToken' },
'payload': JSON.stringify(data)
};
var response = UrlFetchApp.fetch(url, options);
参考:
我正在利用 Google 驱动器 API v3 的权限端点调用将 reader 和编写器状态分配给共享 google 应用程序脚本中的文件夹驾驶。主要目标是在与用户共享权限时不发送通知电子邮件。我在请求正文中包含了参数 'sendNotificationEmail: false',但是仍在发送电子邮件通知用户。我正在使用的代码片段如下。我是否在请求的错误部分包含了 'sendNotificationEmail' 参数?
if (currTabName == "Testing" && curRange.getColumn() == 2){
for (var i = row; i < (row+rows); i++) {
var Email = currSS.getRange(i,2,1,1).getValue();
try{
var url = 'https://www.googleapis.com/drive/v3/files/FileID/permissions';
var data = {
'role': 'writer',
'type': 'user',
'sendNotificationEmail': false,
'emailAddress': Email,
'supportsAllDrives': true,
}
var options = {
'method' : 'POST',
'contentType': 'application/json',
'headers' : { Authorization: 'Bearer ' + 'yourAccessToken' },
'payload' : JSON.stringify(data) // Convert JavaScript object to JSON string
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response);
}
catch(err) {
Logger.log(err.message);
在Permissions: create of Drive API的方法中,查询参数中需要包含sendNotificationEmail
和supportsAllDrives
。我认为这就是你的问题的原因。那么下面的修改呢?
发件人:
var url = 'https://www.googleapis.com/drive/v3/files/folderthatstatusisgrantedfor/permissions';
var data = {
'role': 'writer',
'type': 'user',
'sendNotificationEmail': false,
'emailAddress': Email,
'supportsAllDrives': true,
}
var options = {
'method' : 'POST',
'contentType': 'application/json',
'headers' : { Authorization: 'Bearer ' + 'yourAccessToken' },
'payload' : JSON.stringify(data) // Convert JavaScript object to JSON string
};
var response = UrlFetchApp.fetch(url, options);
收件人:
var folderId = "###"; // Please set the folder ID.
var url = `https://www.googleapis.com/drive/v3/files/${folderId}/permissions`;
url += "?sendNotificationEmail=false&supportsAllDrives=true";
var data = {
'role': 'writer',
'type': 'user',
'emailAddress': Email,
}
var options = {
'method': 'POST',
'contentType': 'application/json',
'headers': { Authorization: 'Bearer ' + 'yourAccessToken' },
'payload': JSON.stringify(data)
};
var response = UrlFetchApp.fetch(url, options);