Janek Kurzydło
Janek Kurzydło

Reputation: 41

#next_sync_token fo Google Calendar Events always return nil

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.

Upvotes: 4

Views: 1005

Answers (3)

Gregory Furmanek
Gregory Furmanek

Reputation: 364

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

Upvotes: 0

Guy de Carufel
Guy de Carufel

Reputation: 476

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.

Upvotes: 12

luc
luc

Reputation: 3782

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.

Upvotes: 0

Related Questions