I need to update the name of some Google Calendar events, once I get them through JavaScript. I only have the sample code which Google shows in their Google Developer site,
/**
* Update an event
*/
function updateEvent(eventId) {
if (eventId) {
var eventToUpdate = gapi.client.calendar.events.get({
"calendarId": 'primary',
"eventId": eventId
});
eventToUpdate.summary = $("#update-name").val(); //Replace with your values of course :)
eventToUpdate.location = $("#update-location").val();
eventToUpdate.description = $("#update-description").val();
eventToUpdate.start = {
'dateTime': (new Date(2017, 04, 22, 8, 00, 00)).toISOString(), //2017-04-22 08h00m00s
'timeZone': 'Europe/Paris'
};
eventToUpdate.end = {
'dateTime': (new Date(2017, 04, 22, 9, 00, 00)).toISOString(), //2017-04-22 09h00m00s
'timeZone': 'Europe/Paris'
};
var request = gapi.client.calendar.events.patch({
'calendarId': 'primary',
'eventId':eventId,
'resource': eventToUpdate
});
request.execute(function(event) {
console.log('Event updated: ' + event.htmlLink);
//Action. Maybe refresh your events list ? :)
});
}
}