I am utilizing the Permissions endpoint call of the Google Drive API v3 to assign reader and writer status to a folder within app scripts for a shared google drive. The main goal is to not send the notification email when the permission is shared with a user. I have included the parameter 'sendNotificationEmail: false' in the body of the request however the email is still being sent notifying the user. The code snippet that I am using is below. Am I including the 'sendNotificationEmail' parameter in the wrong part of the request?
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);
At the method of Permissions: create of Drive API, sendNotificationEmail
and supportsAllDrives
are required to be included in the query parameter. I think that this is the reason for your issue. So how about the following modification?
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);