Home > Mobile >  Google Calendar API Gives More Info Than Desired
Google Calendar API Gives More Info Than Desired

Time:07-01

I am a beginner programmer so pls no hate.

I have the following call:

        eevents = service.events().list(calendarId='primary', pageToken=page_token, timeMax = "2022-07-01T00:00:00Z",
                                       timeMin = "2022-06-28T00:00:00Z").execute()
        for event in events['items']:
            print(event.items())
        page_token = events.get('nextPageToken')
        if not page_token:
           break

But I get events outside the the specified time frame such as:|

('start', {'dateTime': '2022-05-02T10:00:00 02:00', 'timeZone': 'Europe/Prague'}), ('end', {'dateTime': '2022-05-02T11:00:00 02:00', 'timeZone': 'Europe/Prague'}),

Additionally, the expected response at https://developers.google.com/calendar/api/v3/reference/events/list is the following:

{
"kind": "calendar#events",
  "etag": etag,
  "summary": string,
  "description": string,
  "updated": datetime,
  "timeZone": string,
  "accessRole": string,
  "defaultReminders": [
    {
      "method": string,
      "minutes": integer
    }
  ],
  "nextPageToken": string,
  "nextSyncToken": string,
  "items": [
    events Resource
  ]
}

But in addition to the expected dictionary keys and values I get information in tuples. eg.:

('kind', 'calendar#event'), ('etag', '"3306952077924000"'), ('id', '5qcpuj5r1k35v533slhljtgh9g'), ('status', 'confirmed')

This second thing kind of makes sense. I have more than the baseline information in the event, so there is more info adde but since it is more than expected it gets added into tuples.

It really is the first issue of getting events outside scope that bothers me. The second issue is just hunch that the two things could be related.

CodePudding user response:

I'll answer the title question:

for event in events['items']: is looping through the events, where events is a dict specified here

event.items() returns a list of key value pairs as tuples. There is no extra information.

  • Related