Google Calendar Api is not showing event list

2019-07-17 18:08发布

i am trying to retrieve google events for a calendar i am calling this url

GET https://www.googleapis.com/calendar/v3/calendars/riteshmehandiratta%40gmail.com/events

Authorization:  Bearer ya29.AHES6ZSvz3O7V2p7z_k_ZWAiUZqWX35Eyx5V_J4XC5pVSNxLjS6CNzQ

and i am getting response as

{
 "kind": "calendar#events",
 "etag": "\"ZrhdJMCgpoUK_a5fT7XOC6xn46g/_4_AQ2FVvAtAEiDFDj8_pH_usqc\"",
 "summary": "riteshmehandiratta@gmail.com",
 "updated": "2013-02-18T03:45:37.728Z",
 "timeZone": "Asia/Calcutta",
 "accessRole": "owner",
 "defaultReminders": [
  {
   "method": "email",
   "minutes": 10
  },
  {
   "method": "popup",
   "minutes": 10
  }
 ],
 "nextPageToken": "CigKGnR0ZG1xbjAyNHQ1Y3RycjYwY2x0ZGxtcTk0GAEggIDA28aNo-cT"
}

but there are many events exist in the calendar for the past future and for the current date why its not giving the calendar event list?

3条回答
Bombasti
2楼-- · 2019-07-17 18:16

I posted an answer, but was told it wasn't an answer. Regardless, I looped through the requests as I indicated in my original answer until there wasn't a nextPage token and that solved my problem, appending the event lists to a local list. This worked for me and provided a full list of the events. If you want to throw this out too, feel free.

查看更多
迷人小祖宗
3楼-- · 2019-07-17 18:22

I saw the same problem. Sometimes the list API will return an empty item list with a nextPageToken, even if I did not limit the number of responses. The solution is to check if there is a nextPageToken, and make another request for the next page until you get a response without a nextPageToken.

查看更多
一夜七次
4楼-- · 2019-07-17 18:29

there is definitely something weird here, in the response you are posting, i see you are getting the nextPageToken tag, so there actually ARE more results, you can call the next result "page", using a similar request with the variable pageToken added, something like

GET https://www.googleapis.com/calendar/v3/calendars/riteshmehandiratta%40gmail.com/events?pageToken=CigKGnR0ZG1xbjAyNHQ1Y3RycjYwY2x0ZGxtcTk0GAEggIDA28aNo-cT

that way you'll get more results.

Anyway this is weird because the nextPageToken doesn't show up if you don't limit the query with some variable like maxResults. Please check if you are not limiting the query somewhere else.

Maybe you can find useful for making test, the documentation page, that has at the bottom a request form that can build the query for you.

Hope this helps, regards

查看更多
登录 后发表回答