VB.NET Google Calendar: Get Instances of a Recurring Event

Back to Index

Returns instances of the specified recurring event.
This example gets instances for an event from the calendar having the ID = "support@chilkatcloud.com", where the event ID equals "6li3bfqqq65edprt4ms6vdld2j"

Documentation: https://developers.google.com/google-apps/calendar/v3/reference/events/instances


Dim rest As New Chilkat.Rest
Dim success As Boolean

'   Provide a previously obtained OAuth2 access token.
Dim oauth2 As New Chilkat.OAuth2
oauth2.AccessToken = "OAUTH2_ACCESS_TOKEN"
rest.SetAuthOAuth2(oauth2)

success = rest.Connect("www.googleapis.com",443,True,True)
If (success <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


Dim sbJson As New Chilkat.StringBuilder
success = rest.FullRequestNoBodySb("GET","/calendar/v3/calendars/support@chilkatcloud.com/events/6li3bfqqq65edprt4ms6vdld2j/instances",sbJson)
If (success <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


If (rest.ResponseStatusCode <> 200) Then
    Debug.WriteLine("Received error response code: " & rest.ResponseStatusCode)
    Debug.WriteLine("Response body:")
    Debug.WriteLine(sbJson.GetAsString())
    Exit Sub
End If


Dim json As New Chilkat.JsonObject
json.LoadSb(sbJson)

'  The following code parses the JSON response.
'  A sample JSON response is shown below the sample code.
Dim kind As String
Dim etag As String
Dim summary As String
Dim updated As String
Dim timeZone As String
Dim accessRole As String
Dim nextSyncToken As String
Dim i As Integer
Dim count_i As Integer
Dim method As String
Dim minutes As Integer
Dim id As String
Dim status As String
Dim htmlLink As String
Dim created As String
Dim description As String
Dim location As String
Dim creatorEmail As String
Dim creatorSelf As Boolean
Dim organizerEmail As String
Dim organizerSelf As Boolean
Dim startDateTime As String
Dim startTimeZone As String
Dim endDateTime As String
Dim endTimeZone As String
Dim recurringEventId As String
Dim originalStartTimeDateTime As String
Dim originalStartTimeTimeZone As String
Dim iCalUID As String
Dim sequence As Integer
Dim hangoutLink As String
Dim remindersUseDefault As Boolean
Dim j As Integer
Dim count_j As Integer

kind = json.StringOf("kind")
etag = json.StringOf("etag")
summary = json.StringOf("summary")
updated = json.StringOf("updated")
timeZone = json.StringOf("timeZone")
accessRole = json.StringOf("accessRole")
nextSyncToken = json.StringOf("nextSyncToken")
i = 0
count_i = json.SizeOfArray("defaultReminders")
While i < count_i
    json.I = i
    method = json.StringOf("defaultReminders[i].method")
    minutes = json.IntOf("defaultReminders[i].minutes")
    i = i + 1
End While
i = 0
count_i = json.SizeOfArray("items")
While i < count_i
    json.I = i
    kind = json.StringOf("items[i].kind")
    etag = json.StringOf("items[i].etag")
    id = json.StringOf("items[i].id")
    status = json.StringOf("items[i].status")
    htmlLink = json.StringOf("items[i].htmlLink")
    created = json.StringOf("items[i].created")
    updated = json.StringOf("items[i].updated")
    summary = json.StringOf("items[i].summary")
    description = json.StringOf("items[i].description")
    location = json.StringOf("items[i].location")
    creatorEmail = json.StringOf("items[i].creator.email")
    creatorSelf = json.BoolOf("items[i].creator.self")
    organizerEmail = json.StringOf("items[i].organizer.email")
    organizerSelf = json.BoolOf("items[i].organizer.self")
    startDateTime = json.StringOf("items[i].start.dateTime")
    startTimeZone = json.StringOf("items[i].start.timeZone")
    endDateTime = json.StringOf("items[i].end.dateTime")
    endTimeZone = json.StringOf("items[i].end.timeZone")
    recurringEventId = json.StringOf("items[i].recurringEventId")
    originalStartTimeDateTime = json.StringOf("items[i].originalStartTime.dateTime")
    originalStartTimeTimeZone = json.StringOf("items[i].originalStartTime.timeZone")
    iCalUID = json.StringOf("items[i].iCalUID")
    sequence = json.IntOf("items[i].sequence")
    hangoutLink = json.StringOf("items[i].hangoutLink")
    remindersUseDefault = json.BoolOf("items[i].reminders.useDefault")
    j = 0
    count_j = json.SizeOfArray("items[i].reminders.overrides")
    While j < count_j
        json.J = j
        method = json.StringOf("items[i].reminders.overrides[j].method")
        minutes = json.IntOf("items[i].reminders.overrides[j].minutes")
        j = j + 1
    End While
    i = i + 1
End While



Debug.WriteLine("Example Completed.")

Sample JSON Response Body

{
  "kind": "calendar#events",
  "etag": "\"p33se7k7armnte0g\"",
  "summary": "support@chilkatcloud.com",
  "updated": "2017-11-08T19:40:49.131Z",
  "timeZone": "America/Chicago",
  "accessRole": "owner",
  "defaultReminders": [
    {
      "method": "popup",
      "minutes": 10
    }
  ],
  "nextSyncToken": "CPjj0Ordr9cCEPjj0Ordr9cCGAU=",
  "items": [
    {
      "kind": "calendar#event",
      "etag": "\"3020339874608000\"",
      "id": "6li3bfqqq65edprt4ms6vdld2j_20171111T000000Z",
      "status": "confirmed",
      "htmlLink": "https://www.google.com/calendar/event?eid=NmxpM2JmcXFxNjVlZHBydDRtczZ2ZGxkMmpfMjAxNzExMTFUMDAwMDAwWiBzdXBwb3J0QGNoaWxrYXRjbG91ZC5jb20",
      "created": "2017-11-08T19:35:30.000Z",
      "updated": "2017-11-08T19:40:49.019Z",
      "summary": "TGIF Happy Hour",
      "description": "Friday Night Happy Hour",
      "location": "Shannon's Irish Pub, 428 N Main St, Glen Ellyn, IL 60137, USA",
      "creator": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "organizer": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "start": {
        "dateTime": "2017-11-10T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "end": {
        "dateTime": "2017-11-10T19:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "recurringEventId": "6li3bfqqq65edprt4ms6vdld2j",
      "originalStartTime": {
        "dateTime": "2017-11-10T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "iCalUID": "6li3bfqqq65edprt4ms6vdld2j@google.com",
      "sequence": 1,
      "hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.6li3bfqqq65edprt4ms6vdld2j",
      "reminders": {
        "useDefault": false,
        "overrides": [
          {
            "method": "popup",
            "minutes": 180
          }
        ]
      }
    },
    {
      "kind": "calendar#event",
      "etag": "\"3020339874608000\"",
      "id": "6li3bfqqq65edprt4ms6vdld2j_20171118T000000Z",
      "status": "confirmed",
      "htmlLink": "https://www.google.com/calendar/event?eid=NmxpM2JmcXFxNjVlZHBydDRtczZ2ZGxkMmpfMjAxNzExMThUMDAwMDAwWiBzdXBwb3J0QGNoaWxrYXRjbG91ZC5jb20",
      "created": "2017-11-08T19:35:30.000Z",
      "updated": "2017-11-08T19:40:49.019Z",
      "summary": "TGIF Happy Hour",
      "description": "Friday Night Happy Hour",
      "location": "Shannon's Irish Pub, 428 N Main St, Glen Ellyn, IL 60137, USA",
      "creator": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "organizer": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "start": {
        "dateTime": "2017-11-17T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "end": {
        "dateTime": "2017-11-17T19:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "recurringEventId": "6li3bfqqq65edprt4ms6vdld2j",
      "originalStartTime": {
        "dateTime": "2017-11-17T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "iCalUID": "6li3bfqqq65edprt4ms6vdld2j@google.com",
      "sequence": 1,
      "hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.6li3bfqqq65edprt4ms6vdld2j",
      "reminders": {
        "useDefault": false,
        "overrides": [
          {
            "method": "popup",
            "minutes": 180
          }
        ]
      }
    },
    {
      "kind": "calendar#event",
      "etag": "\"3020339874608000\"",
      "id": "6li3bfqqq65edprt4ms6vdld2j_20171125T000000Z",
      "status": "confirmed",
      "htmlLink": "https://www.google.com/calendar/event?eid=NmxpM2JmcXFxNjVlZHBydDRtczZ2ZGxkMmpfMjAxNzExMjVUMDAwMDAwWiBzdXBwb3J0QGNoaWxrYXRjbG91ZC5jb20",
      "created": "2017-11-08T19:35:30.000Z",
      "updated": "2017-11-08T19:40:49.019Z",
      "summary": "TGIF Happy Hour",
      "description": "Friday Night Happy Hour",
      "location": "Shannon's Irish Pub, 428 N Main St, Glen Ellyn, IL 60137, USA",
      "creator": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "organizer": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "start": {
        "dateTime": "2017-11-24T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "end": {
        "dateTime": "2017-11-24T19:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "recurringEventId": "6li3bfqqq65edprt4ms6vdld2j",
      "originalStartTime": {
        "dateTime": "2017-11-24T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "iCalUID": "6li3bfqqq65edprt4ms6vdld2j@google.com",
      "sequence": 1,
      "hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.6li3bfqqq65edprt4ms6vdld2j",
      "reminders": {
        "useDefault": false,
        "overrides": [
          {
            "method": "popup",
            "minutes": 180
          }
        ]
      }
    },
    {
      "kind": "calendar#event",
      "etag": "\"3020339874608000\"",
      "id": "6li3bfqqq65edprt4ms6vdld2j_20171202T000000Z",
      "status": "confirmed",
      "htmlLink": "https://www.google.com/calendar/event?eid=NmxpM2JmcXFxNjVlZHBydDRtczZ2ZGxkMmpfMjAxNzEyMDJUMDAwMDAwWiBzdXBwb3J0QGNoaWxrYXRjbG91ZC5jb20",
      "created": "2017-11-08T19:35:30.000Z",
      "updated": "2017-11-08T19:40:49.019Z",
      "summary": "TGIF Happy Hour",
      "description": "Friday Night Happy Hour",
      "location": "Shannon's Irish Pub, 428 N Main St, Glen Ellyn, IL 60137, USA",
      "creator": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "organizer": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "start": {
        "dateTime": "2017-12-01T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "end": {
        "dateTime": "2017-12-01T19:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "recurringEventId": "6li3bfqqq65edprt4ms6vdld2j",
      "originalStartTime": {
        "dateTime": "2017-12-01T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "iCalUID": "6li3bfqqq65edprt4ms6vdld2j@google.com",
      "sequence": 1,
      "hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.6li3bfqqq65edprt4ms6vdld2j",
      "reminders": {
        "useDefault": false,
        "overrides": [
          {
            "method": "popup",
            "minutes": 180
          }
        ]
      }
    }
  ]
}