I am trying to add an event to a particular calendar in my calendar list using the recommended Javascript code provided by the Google Calendar API guide (link below) https://developers.google.com/google-apps/calendar/v3/reference/events/insert
The code that I am using is nearly identical to the one provided by the API but it isn't working for some reason. The function draws the event properties from a form, assigns them to an event object and tries to add it to the calendar with the specified calendarId. It doesn't throw any errors but it does not add to the calendar even though it has authorization and is accessing the calendar in other parts of the program. Can anyone see what I am doing wrong or know how to make it work?
Here is the code I am using:
function createNewEvent() {
var sum = $("#eventName").val();
var loc = $("#location").val();
var desc = $("#descrip").val();
var strt = $("#StartDateTime").val() + "+00:00";
var endt = $("#EndDateTime").val() + "+00:00";
var calId = $("#calendarList").val();
var event = {
'summary': sum,
'location': loc,
'description': desc,
'start': { 'dateTime': strt },
'end': { 'dateTime': endt }
};
var request = gapi.client.calendar.events.insert({
'calendarId' : calId,
'resource' : event
});
request.execute(function (event) {
appendPre('Event created: ' + event.htmlLink);
});
}