8
votes

Recently after adding new events in Google calendar and try to fetch it from Google calendar API, I never get the new events list for the primary calendarId of my account.

Also I tried to fetch from developer console: https://developers.google.com/google-apps/calendar/v3/reference/events/list#try-it which gives the same empty list of items as response, even though the future events exists.

But I am able to fetch the events list of other calendar list. eg. Holidays, shared calendar from friends etc.

2
Are you authenticated? Do you get any error? Could you try performing an insert event operation on your primary calendar via the #try-it and see if that event gets listed?luc
Yes, creation of events from the API from my primary calendarId is not an issue. I see that events gets created in the calendar. But when I try to fetch these events from the API, I get nothing in the response.Suhas Giriraj
More questions: Can you perform a get for the event you just insterted and see if it is there? Can you see those events in the web UI?luc
@SuhasGiriraj Was this issue resolved?Matt
Same problem here. A secondary calendar with plenty of recurring events (visible in web GUI) but using python API, events().list() does NOT return any events. Setting singleEvents=True returns the instances, but that list is way too big so not a proper solution. Bug in google calendar API?Davy

2 Answers

4
votes

I also had the problem of events().list(calendarId=<calendar_id>, singleEvents=False) not returning any events (using python API). I tested with a secondary calendar with one recurring event. Solved by adding parameter maxResults=9999. It turned out that maxResults value 1413 or higher is needed to return the event. Weird, seems to be a bug.

5
votes

Try adding singleEvents:true to your request.

I was having the same issue. In my case, using Javascript, this works (returns several single, non-recurring events) :

  var calendar = googleapis.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 callback(err);
    }
    console.log(response); 
    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);
      }
      return callback(null, events); 
    }
  });

But this does not (doesn't return any events including those that are on the 'primary' calendar and are single, non-recurring events). The only difference from above code is singleEvents parameter is commented out so it's value will default to false.

  var calendar = googleapis.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 callback(err);
    }
    console.log(response); 
    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);
      }
      return callback(null, events); 
    }
  });