Moves an event to another calendar, i.e. changes an event's organizer.
This example moves event ID="35ocdnnjofbtfs6c602uqvdg9u" from the calendar (ID = "support@chilkatcloud.com") to the calendar (ID = "chilkatcloud.com_su2u8trmo6rlq2jh6cr9hb032o@group.calendar.google.com")
#include <C_CkRest.h>
#include <C_CkOAuth2.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>
void ChilkatSample(void)
{
HCkRest rest;
BOOL success;
HCkOAuth2 oauth2;
HCkStringBuilder sbReq;
HCkStringBuilder sbJson;
HCkJsonObject json;
const char *kind;
const char *etag;
const char *id;
const char *status;
const char *htmlLink;
const char *created;
const char *updated;
const char *summary;
const char *description;
const char *location;
const char *creatorEmail;
BOOL creatorSelf;
const char *organizerEmail;
const char *organizerDisplayName;
const char *startDateTime;
const char *endDateTime;
const char *iCalUID;
int sequence;
const char *hangoutLink;
BOOL remindersUseDefault;
int i;
int count_i;
const char *email;
const char *responseStatus;
BOOL self;
rest = CkRest_Create();
// Provide a previously obtained OAuth2 access token.
oauth2 = CkOAuth2_Create();
CkOAuth2_putAccessToken(oauth2,"OAUTH2_ACCESS_TOKEN");
CkRest_SetAuthOAuth2(rest,oauth2);
success = CkRest_Connect(rest,"www.googleapis.com",443,TRUE,TRUE);
if (success != TRUE) {
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
CkOAuth2_Dispose(oauth2);
return;
}
CkRest_AddQueryParam(rest,"destination","chilkatcloud.com_su2u8trmo6rlq2jh6cr9hb032o@group.calendar.google.com");
sbReq = CkStringBuilder_Create();
sbJson = CkStringBuilder_Create();
success = CkRest_FullRequestSb(rest,"POST","/calendar/v3/calendars/support@chilkatcloud.com/events/35ocdnnjofbtfs6c602uqvdg9u/move",sbReq,sbJson);
if (success != TRUE) {
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
CkOAuth2_Dispose(oauth2);
CkStringBuilder_Dispose(sbReq);
CkStringBuilder_Dispose(sbJson);
return;
}
if (CkRest_getResponseStatusCode(rest) != 200) {
printf("Received error response code: %d\n",CkRest_getResponseStatusCode(rest));
printf("Response body:\n");
printf("%s\n",CkStringBuilder_getAsString(sbJson));
CkRest_Dispose(rest);
CkOAuth2_Dispose(oauth2);
CkStringBuilder_Dispose(sbReq);
CkStringBuilder_Dispose(sbJson);
return;
}
json = CkJsonObject_Create();
CkJsonObject_LoadSb(json,sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
kind = CkJsonObject_stringOf(json,"kind");
etag = CkJsonObject_stringOf(json,"etag");
id = CkJsonObject_stringOf(json,"id");
status = CkJsonObject_stringOf(json,"status");
htmlLink = CkJsonObject_stringOf(json,"htmlLink");
created = CkJsonObject_stringOf(json,"created");
updated = CkJsonObject_stringOf(json,"updated");
summary = CkJsonObject_stringOf(json,"summary");
description = CkJsonObject_stringOf(json,"description");
location = CkJsonObject_stringOf(json,"location");
creatorEmail = CkJsonObject_stringOf(json,"creator.email");
creatorSelf = CkJsonObject_BoolOf(json,"creator.self");
organizerEmail = CkJsonObject_stringOf(json,"organizer.email");
organizerDisplayName = CkJsonObject_stringOf(json,"organizer.displayName");
startDateTime = CkJsonObject_stringOf(json,"start.dateTime");
endDateTime = CkJsonObject_stringOf(json,"end.dateTime");
iCalUID = CkJsonObject_stringOf(json,"iCalUID");
sequence = CkJsonObject_IntOf(json,"sequence");
hangoutLink = CkJsonObject_stringOf(json,"hangoutLink");
remindersUseDefault = CkJsonObject_BoolOf(json,"reminders.useDefault");
i = 0;
count_i = CkJsonObject_SizeOfArray(json,"attendees");
while (i < count_i) {
CkJsonObject_putI(json,i);
email = CkJsonObject_stringOf(json,"attendees[i].email");
responseStatus = CkJsonObject_stringOf(json,"attendees[i].responseStatus");
self = CkJsonObject_BoolOf(json,"attendees[i].self");
i = i + 1;
}
printf("Example Completed.\n");
CkRest_Dispose(rest);
CkOAuth2_Dispose(oauth2);
CkStringBuilder_Dispose(sbReq);
CkStringBuilder_Dispose(sbJson);
CkJsonObject_Dispose(json);
}
{
"kind": "calendar#event",
"etag": "\"3020341523602000\"",
"id": "35ocdnnjofbtfs6c602uqvdg9u",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=MzVvY2RubmpvZmJ0ZnM2YzYwMnVxdmRnOXUgc3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t",
"created": "2017-11-08T18:25:38.000Z",
"updated": "2017-11-08T19:52:41.801Z",
"summary": "QXQC",
"description": "20th Annual QXQC Gathering",
"location": "Quigley's Irish Pub, 43 E Jefferson Ave, Naperville, IL 60540, USA",
"creator": {
"email": "support@chilkatcloud.com",
"self": true
},
"organizer": {
"email": "chilkatcloud.com_su2u8trmo6rlq2jh6cr9hb032o@group.calendar.google.com",
"displayName": "Party Calendar"
},
"start": {
"dateTime": "2017-11-09T20:00:00-06:00"
},
"end": {
"dateTime": "2017-11-09T23:00:00-06:00"
},
"iCalUID": "35ocdnnjofbtfs6c602uqvdg9u@google.com",
"sequence": 0,
"attendees": [
{
"email": "dean@example.com",
"responseStatus": "needsAction"
},
{
"email": "support@chilkatcloud.com",
"self": true,
"responseStatus": "accepted"
},
{
"email": "ajay@example.com",
"responseStatus": "needsAction"
},
{
"email": "jim@example.com",
"responseStatus": "needsAction"
},
{
"email": "gilian@example.com",
"responseStatus": "needsAction"
}
],
"hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.35ocdnnjofbtfs6c602uqvdg9u",
"reminders": {
"useDefault": true
}
}