4

I created 3 events in Calendar, then I run

response = @client.execute!(
   :api_method => @calendar_api.events.list,
   :parameters => {
     :calendarId => "primary",
     :maxResults => 10,
     :singleEvents => true,
     :orderBy => 'startTime'}
 )

I received 3 items but #next_sync_token method called on response.data returns nil (#next_page_token also returns nil but in this case it is correct). I tried to set :fields parameter to "nextSyncToken" but still nothing. I also made some updates on that events and #next_sync_token was still set to nil..Am I wrong? Maybe I made some mistake ? The call only with calendarId in parameters do the same.

3 Answers3

12

Get rid of orderBy. This isn't documented, but if you try the Google API, you'll see that nextSyncToken isn't returned with orderBy: startTime.

Wasted lots of time on the same issue.

Guy de Carufel
  • 466
  • 4
  • 8
0

The result will only have the next sync token on the last page. You need to go over all the pages (until next_page_token nil) and then you will find a sync token.

luc
  • 3,642
  • 1
  • 18
  • 21
  • Yes It is true and I know this, but here I have only 3 events so I have only 1 page and it is the last. In this case I think that #next_sync_token should respond with proper token. I also see that response.body contains nextSyncToken, so that method should work – Janek Kurzydło Dec 01 '15 at 14:21
0

One more thing to try if you aren't getting the next_sync_token is to add it to the fields parameter:

Example:

params = {
  max_results: 100,
  fields: 'items(id,summary,description),next_sync_token',
}

result = calendar_service.list_events 'primary', **params
Gregory Furmanek
  • 364
  • 1
  • 13