Updates an event. (This example modifies the start/end date/time for the event id 52e7uk7j7vl5dosj7b25memov0 in the calendar with id = "support@chilkatcloud.com".)
load ./chilkat.dll
set rest [new_CkRest]
# Provide a previously obtained OAuth2 access token.
set oauth2 [new_CkOAuth2]
CkOAuth2_put_AccessToken $oauth2 "OAUTH2_ACCESS_TOKEN"
CkRest_SetAuthOAuth2 $rest $oauth2
set success [CkRest_Connect $rest "www.googleapis.com" 443 1 1]
if {[expr $success != 1]} then {
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
delete_CkOAuth2 $oauth2
exit
}
# The following code creates the JSON request body.
# The JSON created by this code is shown below.
set jsonReq [new_CkJsonObject]
CkJsonObject_UpdateString $jsonReq "start.dateTime" "2017-11-27T10:30:00-06:00"
CkJsonObject_UpdateString $jsonReq "end.dateTime" "2017-11-27T11:30:00-06:00"
set sbReq [new_CkStringBuilder]
CkJsonObject_EmitSb $jsonReq $sbReq
CkRest_AddHeader $rest "Content-Type" "application/json"
set sbJson [new_CkStringBuilder]
set success [CkRest_FullRequestSb $rest "PATCH" "/calendar/v3/calendars/support@chilkatcloud.com/events/52e7uk7j7vl5dosj7b25memov0" $sbReq $sbJson]
if {[expr $success != 1]} then {
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
delete_CkOAuth2 $oauth2
delete_CkJsonObject $jsonReq
delete_CkStringBuilder $sbReq
delete_CkStringBuilder $sbJson
exit
}
if {[expr [CkRest_ResponseStatusCode $rest] != 200]} then {
puts "Received error response code: [CkRest_ResponseStatusCode $rest]"
puts "Response body:"
puts [CkStringBuilder_getAsString $sbJson]
delete_CkRest $rest
delete_CkOAuth2 $oauth2
delete_CkJsonObject $jsonReq
delete_CkStringBuilder $sbReq
delete_CkStringBuilder $sbJson
exit
}
set json [new_CkJsonObject]
CkJsonObject_LoadSb $json $sbJson
# The following code parses the JSON response.
# A sample JSON response is shown below the sample code.
set kind [CkJsonObject_stringOf $json "kind"]
set etag [CkJsonObject_stringOf $json "etag"]
set id [CkJsonObject_stringOf $json "id"]
set status [CkJsonObject_stringOf $json "status"]
set htmlLink [CkJsonObject_stringOf $json "htmlLink"]
set created [CkJsonObject_stringOf $json "created"]
set updated [CkJsonObject_stringOf $json "updated"]
set summary [CkJsonObject_stringOf $json "summary"]
set creatorEmail [CkJsonObject_stringOf $json "creator.email"]
set creatorSelf [CkJsonObject_BoolOf $json "creator.self"]
set organizerEmail [CkJsonObject_stringOf $json "organizer.email"]
set organizerSelf [CkJsonObject_BoolOf $json "organizer.self"]
set startDateTime [CkJsonObject_stringOf $json "start.dateTime"]
set endDateTime [CkJsonObject_stringOf $json "end.dateTime"]
set iCalUID [CkJsonObject_stringOf $json "iCalUID"]
set sequence [CkJsonObject_IntOf $json "sequence"]
set hangoutLink [CkJsonObject_stringOf $json "hangoutLink"]
set remindersUseDefault [CkJsonObject_BoolOf $json "reminders.useDefault"]
puts "Example Completed."
delete_CkRest $rest
delete_CkOAuth2 $oauth2
delete_CkJsonObject $jsonReq
delete_CkStringBuilder $sbReq
delete_CkStringBuilder $sbJson
delete_CkJsonObject $json
{
"start": {
"dateTime": "2017-11-27T10:30:00-06:00"
},
"end": {
"dateTime": "2017-11-27T11:30:00-06:00"
}
}
{
"kind": "calendar#event",
"etag": "\"3020353646374000\"",
"id": "52e7uk7j7vl5dosj7b25memov0",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=NTJlN3VrN2o3dmw1ZG9zajdiMjVtZW1vdjAgc3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t",
"created": "2017-11-08T21:27:50.000Z",
"updated": "2017-11-08T21:33:43.187Z",
"summary": "Dentist Appointment",
"creator": {
"email": "support@chilkatcloud.com",
"self": true
},
"organizer": {
"email": "support@chilkatcloud.com",
"self": true
},
"start": {
"dateTime": "2017-11-27T10:30:00-06:00"
},
"end": {
"dateTime": "2017-11-27T11:30:00-06:00"
},
"iCalUID": "52e7uk7j7vl5dosj7b25memov0@google.com",
"sequence": 1,
"hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.52e7uk7j7vl5dosj7b25memov0",
"reminders": {
"useDefault": true
}
}