I used the code sample in Quickstart and tried inserting an event using the example on - https://developers.google.com/calendar/v3/reference/events/insert#examples
I checked the resources available over the web and none of them seem to be working for me (downgrading googleapis package to version 24.0.0 or using different ways of writing the insert event). This is the code of the addEvents function currently -
function addEvents(auth){
var event = {
"summary": "Google I/O 2015",
"location": "800 Howard St., San Francisco, CA 94103",
"description": "A chance to hear more about Google's developer products.",
"start": {
"dateTime": "2015-05-28T09:00:00-07:00",
"timeZone": "America/Los_Angeles",
},
"end": {
"dateTime": "2015-05-28T17:00:00-07:00",
"timeZone": "America/Los_Angeles",
},
"recurrence": [
"RRULE:FREQ=DAILY;COUNT=2"
],
"reminders": {
"useDefault": false,
"overrides": [
{"method": "email", "minutes": 24 * 60},
{"method": "popup", "minutes": 10},
],
},
};
//console.log(event)
var calendar = google.calendar("v3");
calendar.events.insert({
auth: auth,
calendarId: "primary",
resource: event,
}, function(err, event) {
if (err) {
console.log("There was an error contacting the Calendar service: " + err);
return;
}
console.log("Event created: %s", event.htmlLink);
});
}
It is on the same lines as the listEvents function -
function listEvents(auth) {
var calendar = google.calendar('v3');
calendar.events.list({
auth: auth,
calendarId: 'primary',
timeMin: (new Date()).toISOString(),
maxResults: 10,
singleEvents: true,
orderBy: 'startTime'
},
function(err, response) {
if (err) {
console.log('The API returned an error: ' + err);
return;
}
var events = response.items;
if (events.length == 0) {
console.log('No upcoming events found.');
}
else {
console.log('Upcoming 10 events:');
for (var i = 0; i < events.length; i++) {
var event = events[i];
var start = event.start.dateTime || event.start.date;
console.log('%s - %s', start, event.summary);
}
}
});
}
Can anyone please help me with this?
Thanks!