wanasit / google-calendar

Google Calendar API connection in Node.js
MIT License
230 stars 54 forks source link

Events Insert #26

Open DenisMrGnusa opened 5 years ago

DenisMrGnusa commented 5 years ago

Please help, I have tried creating new events using this package, my code is like this : var google_calendar = new gcal.GoogleCalendar(req.user.token); var resource = { 'summary': 'Google I/O 2019', 'location': '800 Howard St., San Francisco, CA 94103', 'description': 'A chance to hear more about Google\'s developer products.', "guestsCanInviteOthers": false, 'start': { 'dateTime': '2019-01-27T04:00:00+07:00', 'timeZone': 'Asia/Jakarta', }, 'end': { 'dateTime': '2019-01-28T04:00:00+07:00', 'timeZone': 'Asia/Jakarta', }, "attachments": [ { "fileId": "1", "fileUrl": "https://gnusa.id/asset/img/preloader-image-retina-2.png", "iconLink": "https://gnusa.id/asset/img/preloader-image-retina-2.png", "mimeType": "image/png", "title": "Logo Gnusa" } ], 'attendees': [ { 'email': 'denis.mr.gnusa@gmail.com', "displayName": "Denis Muhammad Ramdan", "comment": "Pembicara dari PT. Gateway Internusa", "organizer": false } ], 'reminders': { 'useDefault': false, 'overrides': [ {'method': 'email', 'minutes': 24 * 60}, {'method': 'popup', 'minutes': 10} ], }, };

google_calendar.events.insert('primary',{
    'sendNotifications': true,
    'resource': resource,
}, function(err, event) {
    if (err) {
        console.log('There was an error contacting the Calendar service: ' + JSON.stringify(err));
        return;
    }
    console.log('Event created: %s', event.htmlLink);
});

when the function is executed, the return results are as follows:

There was an error contacting the Calendar service: {"errors":[{"domain":"global","reason":"required","message":"Missing end time."}],"code":400,"message":"Missing end time."}

and the event does not enter the calendar, my question, why did that happen? Am I writing wrong? if yes, how is the correct writing, thank you