WSI Appfactory
WSI Appfactory

Reputation: 67

Google Calendar - SyncToken is missing in API response

I don't see nextSyncToken in the response. I followed the doc(https://developers.google.com/calendar/api/guides/sync) and paginated using nextPageToken but I couldn't see the nextSyncToken on the last page.

API Used: GET /calendars/primary/events?maxResults=10&singleEvents=true&pageToken=********

I don't know whether if I miss anything here. Could anyone help me with this?

Upvotes: 3

Views: 1981

Answers (2)

Kessy
Kessy

Reputation: 2014

I have seen from the response link on the other answer comment that you are using orderBy on the request.

This is why the nextSyncToken is not showing up.

As mentioned on the documentation on Events: list -> Parameters -> syncToken:

Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then. All events deleted since the previous list request will always be in the result set and it is not allowed to set showDeleted to False. There are several query parameters that cannot be specified together with nextSyncToken to ensure consistency of the client state.

These are:

  • iCalUID
  • orderBy
  • privateExtendedProperty
  • q
  • sharedExtendedProperty
  • timeMin
  • timeMax
  • updatedMin

If the syncToken expires, the server will respond with a 410 GONE response code and the client should clear its storage and perform a full synchronization without any syncToken. Learn more about incremental synchronization. Optional. The default is to return all entries.

You should remove the orderBy from the request to get the syncToken

Upvotes: 10

Juljan
Juljan

Reputation: 2546

Could you please provide the response from gcalendar API? It's hard to say more without detail information. I event don't know which language are you using.

  1. Try to use a vendor library to sort that out:

a) https://packagist.org/packages/google/apiclient (for PHP)

b) https://www.npmjs.com/package/google-calendar (for JavaScript)

and/or

  1. Try to use alternative endpoint: GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events.

Upvotes: 0

Related Questions