I have the following JSON
var resource = {
"summary": "Sample Event",
"start": {
"dateTime": sample1
},
"end": {
"dateTime": twoHoursLater
},
"reminders": {
"useDefault": false,
"overrides": [
{
"method": "popup",
"minutes": "5"
},
{
"method": "email",
"minutes": "5"
}
]
}
};
I can insert it to Google Calendar using the code below
function addEvent() {
gapi.client.load('calendar', 'v3', function() {
var request = gapi.client.calendar.events.insert({
'calendarId': calendarId,
'resource': resource
});
request.execute(function(resp) {
console.log(resp);
});
});
}
In Google Calendar website it appears as:
5 minutes before, as email
5 minutes before
As you can see the event the I have has reminders, meaning it will notify via Popup and Email, 5 minutes before the event starts.
Now, the thing is I want to remove this event reminder programatically using the API.
What I have tried so far:
Test 1:
Based on the documentation https://developers.google.com/calendar/concepts/reminders
It says "To revert back to the default set of reminders, perform an update setting reminders.useDefault back to true."
var resource3 = {
"summary": "Sample Event xx",
"start": {
"dateTime": sample1
},
"end": {
"dateTime": twoHoursLater
},
"reminders": {
"useDefault": true
}
};
function updateEvent(eventId) {
gapi.client.load('calendar', 'v3', function() {
var request = gapi.client.calendar.events.patch({
'calendarId': calendarId,
'eventId': eventId,
'resource': resource3
});
request.execute(function(resp) {
console.log(resp);
});
});
}
The code above will return an error Cannot specify both default reminders and overrides at the same time. in the console.
Test 2:
Based on an accepted answer on stackoverflow Google Calendar API: How to disable Notifications?
It says "Therefore I think you can just set "useDefault": false
and don't supply any overrides, and it should result in the event having no reminders."
var resource3 = {
"summary": "Sample Event xx",
"start": {
"dateTime": sample1
},
"end": {
"dateTime": twoHoursLater
},
"reminders": {
"useDefault": false
}
};
function updateEvent(eventId) {
gapi.client.load('calendar', 'v3', function() {
var request = gapi.client.calendar.events.patch({
'calendarId': calendarId,
'eventId': eventId,
'resource': resource3
});
request.execute(function(resp) {
console.log(resp);
});
});
}
The patching/updating works on other fields such as summary, start, and end. But it does not remove the event reminder.
Test 3:
This is what I have experimented on so far. I removed the reminders completely. Still no luck. Same output as in Test 2.
var resource3 = {
"summary": "Sample Event xx",
"start": {
"dateTime": sample1
},
"end": {
"dateTime": twoHoursLater
}
};
unction updateEvent(eventId) {
gapi.client.load('calendar', 'v3', function() {
var request = gapi.client.calendar.events.patch({
'calendarId': calendarId,
'eventId': eventId,
'resource': resource3
});
request.execute(function(resp) {
console.log(resp);
});
});
}
Do you have any idea on how to remove the event reminder?