Zig Requires Chilkat v11.0.0+
Zig
MS Graph Calendar Update Event
See more Microsoft Calendar Examples
Update the properties of an event object.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = try chilkat.Http.init();
defer http.deinit();
// Implements the following CURL command:
// curl -X PATCH https://graph.microsoft.com/v1.0/me/events/{id} \
// -H "Content-type: application/json" \
// -d '{
// "originalStartTimeZone": "originalStartTimeZone-value",
// "originalEndTimeZone": "originalEndTimeZone-value",
// "responseStatus": {
// "response": "",
// "time": "datetime-value"
// },
// "recurrence": null,
// "iCalUId": "iCalUId-value",
// "reminderMinutesBeforeStart": 99,
// "isOnlineMeeting": true,
// "onlineMeetingProvider": "teamsForBusiness",
// "isReminderOn": true,
// "categories": ["Red category"]
// }'
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "originalStartTimeZone": "originalStartTimeZone-value",
// "originalEndTimeZone": "originalEndTimeZone-value",
// "responseStatus": {
// "response": "",
// "time": "datetime-value"
// },
// "recurrence": null,
// "iCalUId": "iCalUId-value",
// "reminderMinutesBeforeStart": 99,
// "isOnlineMeeting": true,
// "onlineMeetingProvider": "teamsForBusiness",
// "isReminderOn": true,
// "categories": [
// "Red category"
// ]
// }
const json = try chilkat.JsonObject.init();
defer json.deinit();
json.updateString("originalStartTimeZone", "originalStartTimeZone-value") catch {};
json.updateString("originalEndTimeZone", "originalEndTimeZone-value") catch {};
json.updateString("responseStatus.response", "") catch {};
json.updateString("responseStatus.time", "datetime-value") catch {};
json.updateNull("recurrence") catch {};
json.updateString("iCalUId", "iCalUId-value") catch {};
json.updateInt("reminderMinutesBeforeStart", 99) catch {};
json.updateBool("isOnlineMeeting", true) catch {};
json.updateString("onlineMeetingProvider", "teamsForBusiness") catch {};
json.updateBool("isReminderOn", true) catch {};
json.updateString("categories[0]", "Red category") catch {};
http.setRequestHeader("Content-type", "application/json");
const sb_request_body = try chilkat.StringBuilder.init();
defer sb_request_body.deinit();
json.emitSb(sb_request_body) catch {};
const resp = try chilkat.HttpResponse.init();
defer resp.deinit();
http.httpSb("PATCH", "https://graph.microsoft.com/v1.0/me/events/{id}", sb_request_body, "utf-8", "application/json", resp) catch {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
const sb_response_body = try chilkat.StringBuilder.init();
defer sb_response_body.deinit();
resp.getBodySb(sb_response_body) catch {};
const j_resp = try chilkat.JsonObject.init();
defer j_resp.deinit();
j_resp.loadSb(sb_response_body) catch {};
j_resp.setEmitCompact(false);
std.debug.print("Response Body:\n", .{});
std.debug.print("{s}\n", .{try j_resp.emit(alloc)});
const resp_status_code = resp.getStatusCode();
std.debug.print("Response Status Code = {d}\n", .{resp_status_code});
if (resp_status_code >= 400) {
std.debug.print("Response Header:\n", .{});
std.debug.print("{s}\n", .{try resp.getHeader(alloc)});
std.debug.print("Failed.\n", .{});
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "originalStartTimeZone": "originalStartTimeZone-value",
// "originalEndTimeZone": "originalEndTimeZone-value",
// "responseStatus": {
// "response": "",
// "time": "datetime-value"
// },
// "recurrence": null,
// "iCalUId": "iCalUId-value",
// "reminderMinutesBeforeStart": 99,
// "isOnlineMeeting": true,
// "onlineMeetingProvider": "teamsForBusiness",
// "isReminderOn": true,
// "onlineMeeting": {
// "joinUrl": "https://teams.microsoft.com/l/meetup-join/19%3ameeting_NzIyNzhlMGEtM2YyZC00ZmY0LTlhNzUtZmZjNWFmZGNlNzE2%40thread.v2/0?context=%7b%22Tid%22%3a%2272f988bf-86f1-41af-91ab-2d7cd011db47%22%2c%22Oid%22%3a%22bc55b173-cff6-457d-b7a1-64bda7d7581a%22%7d",
// "conferenceId": "177513992",
// "tollNumber": "+91 22 6241 6885"
// }
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
_ = try j_resp.stringOf(alloc, "originalStartTimeZone");
_ = try j_resp.stringOf(alloc, "originalEndTimeZone");
_ = try j_resp.stringOf(alloc, "responseStatus.response");
_ = try j_resp.stringOf(alloc, "responseStatus.time");
_ = try j_resp.stringOf(alloc, "recurrence");
_ = try j_resp.stringOf(alloc, "iCalUId");
_ = j_resp.intOf("reminderMinutesBeforeStart");
_ = j_resp.boolOf("isOnlineMeeting");
_ = try j_resp.stringOf(alloc, "onlineMeetingProvider");
_ = j_resp.boolOf("isReminderOn");
_ = try j_resp.stringOf(alloc, "onlineMeeting.joinUrl");
_ = try j_resp.stringOf(alloc, "onlineMeeting.conferenceId");
_ = try j_resp.stringOf(alloc, "onlineMeeting.tollNumber");
}