Calendar API gives an error while inserting events using events.insert
See original GitHub issueHi, 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!
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (6 by maintainers)
Top Results From Across the Web
Calendar API gives an error while inserting events using ...
Calendar API gives an error while inserting events using events.insert: There was an error contacting the Calendar service: Error: Missing end ...
Read more >Handle API errors | Google Calendar
The rest of this page provides a reference of Calendar errors, with some guidance on ... If you're using Events: insert, Events: import,...
Read more >Time Range Error - Google Groups
I am creating calendar events using the Calendar API v3 (.NET). I can use the events QuickAdd method but receive an errror when...
Read more >How to Use the Google Calendar API With JavaScript - Fusebit
If you don't have any errors in the code, Google Calendar will successfully add the event. List Events Using Google Calendar API. Now...
Read more >error 403: “Calendar usage limits exceeded” when adding ...
When trying to use the Calendar API to 'insert' new events with external attendees, I hit some kind of quota limit after about...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Greetings! Sadly the docs on developers.google.com are out of date; we are working to get them fixed. In the interim - here are a few changes you need to make:
Make sure you didn’t
npm install google-auth-library
. If you did, delete it from your package.json, and runnpm install
again.Import the library using
const {google} = require('googleapis');
, notice the{}
around google.In your callback, instead of looking for
response.items
, useresponse.data.items
. This will be required in any of the callbacks coming from the API.I am guessing that after doing these things, you’ll be back on rails 😃 Let me know if you run into any problems!
if you could share us the snippet it will be very helpful