Creates a new calendar. (i.e. Adds an entry to the user's calendar list.)
Dim rest As Chilkat.Rest
Set rest = Chilkat.NewRest
' Provide a previously obtained OAuth2 access token.
Dim oauth2 As Chilkat.OAuth2
Set oauth2 = Chilkat.NewOAuth2
oauth2.AccessToken = "OAUTH2_ACCESS_TOKEN"
success = rest.SetAuthOAuth2(oauth2)
success = rest.Connect("www.googleapis.com",443,True,True)
If (success <> True) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
' The following code creates the JSON request body.
' The JSON created by this code is shown below.
Dim jsonReq As Chilkat.JsonObject
Set jsonReq = Chilkat.NewJsonObject
success = jsonReq.UpdateString("summary","test calendar abc")
Dim sbReq As Chilkat.StringBuilder
Set sbReq = Chilkat.NewStringBuilder
success = jsonReq.EmitSb(sbReq)
success = rest.AddHeader("Content-Type","application/json")
Dim sbJson As Chilkat.StringBuilder
Set sbJson = Chilkat.NewStringBuilder
success = rest.FullRequestSb("POST","/calendar/v3/calendars",sbReq,sbJson)
If (success <> True) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
If (rest.ResponseStatusCode <> 200) Then
Debug.Print "Received error response code: "; rest.ResponseStatusCode
Debug.Print "Response body:"
Debug.Print sbJson.GetAsString()
Exit Sub
End If
Dim json As Chilkat.JsonObject
Set json = Chilkat.NewJsonObject
success = json.LoadSb(sbJson)
' The following code parses the JSON response.
' A sample JSON response is shown below the sample code.
kind = json.StringOf("kind")
etag = json.StringOf("etag")
id = json.StringOf("id")
summary = json.StringOf("summary")
Debug.Print "Example Completed."
{
"summary": "test calendar abc"
}
{
"kind": "calendar#calendar",
"etag": "\"BKjXnZpXR6E5ueFWG3UJk-2POYg/jb82ZwCZzTu1P_p3WnVVxDoJTeI\"",
"id": "chilkatcloud.com_he3bfm0ljrl7p427u8vjmg9afo@group.calendar.google.com",
"summary": "test calendar abc"
}