I want to send a Google calendar invite using the google apps script but I am encountering an error in the last line of the following code snippet:
function testnotification(){
var calendarId = "####";
var eventId = "###";
var email = ""###@gmail.com
addGuestAndSendEmail(calendarId,eventId,email)
}
function addGuestAndSendEmail(calendarId, eventId, newGuest) {
var calendar = CalendarApp.getCalendarById(calendarId);
var event = calendar.getEventById(eventId);
var attendees = [];
attendees.push({email: newGuest});
var resource = { attendees: attendees };
var args = { sendUpdates: "all" };
calendar.createEvent.patch(resource, calendarId, eventId, args);
}
I have modified last line from Calendar.Events.patch(event, calendar, event.id, args);
to calendar.createEvent.patch(resource, calendarId, eventId, args)
, however when I run, it says:
calendar.createEvent.patch is not a function
I reviewed stackoverflow questions (Q1 , Q2) but couldn't find a way. @Tanaike proposed the following answer, when I ran this script:
function testNotification(){
var calendarId = "###";
var eventId = "###";
var email = "###@gmail.com"
addGuestAndSendEmail(calendarId,eventId,email)
}
function addGuestAndSendEmail(calendarId, eventId, newGuest) {
Calendar.Events.patch({ attendees: [{ email: newGuest }] }, calendarId, eventId, { sendUpdates: "all" });
}
I received the following error:
GoogleJsonResponseException: API call to calendar.events.patch failed with error: Not Found
This calendar is shared with me however, I have the following permissions to this calendar: