Lua Requires Chilkat v11.0.0+
Lua
MS Graph Calendar Update Event
See more Microsoft Calendar Examples
Update the properties of an event object.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local http = chilkat.Http.new()
-- 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"
-- ]
-- }
local json = chilkat.JsonObject.new()
json:update_string("originalStartTimeZone", "originalStartTimeZone-value")
json:update_string("originalEndTimeZone", "originalEndTimeZone-value")
json:update_string("responseStatus.response", "")
json:update_string("responseStatus.time", "datetime-value")
json:update_null("recurrence")
json:update_string("iCalUId", "iCalUId-value")
json:update_int("reminderMinutesBeforeStart", 99)
json:update_bool("isOnlineMeeting", true)
json:update_string("onlineMeetingProvider", "teamsForBusiness")
json:update_bool("isReminderOn", true)
json:update_string("categories[0]", "Red category")
http:set_request_header("Content-type", "application/json")
local sbRequestBody = chilkat.StringBuilder.new()
json:emit_sb(sbRequestBody)
local resp = chilkat.HttpResponse.new()
local success = http:http_sb("PATCH", "https://graph.microsoft.com/v1.0/me/events/{id}", sbRequestBody, "utf-8", "application/json", resp)
if not success then
print(http.last_error_text)
return
end
local sbResponseBody = chilkat.StringBuilder.new()
resp:get_body_sb(sbResponseBody)
local jResp = chilkat.JsonObject.new()
jResp:load_sb(sbResponseBody)
jResp.emit_compact = false
print("Response Body:")
print(jResp:emit())
local respStatusCode = resp.status_code
print("Response Status Code = " .. respStatusCode)
if respStatusCode >= 400 then
print("Response Header:")
print(resp.header)
print("Failed.")
return
end
-- 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
local originalStartTimeZone = jResp:string_of("originalStartTimeZone")
local originalEndTimeZone = jResp:string_of("originalEndTimeZone")
local responseStatusResponse = jResp:string_of("responseStatus.response")
local responseStatusTime = jResp:string_of("responseStatus.time")
local recurrence = jResp:string_of("recurrence")
local iCalUId = jResp:string_of("iCalUId")
local reminderMinutesBeforeStart = jResp:int_of("reminderMinutesBeforeStart")
local isOnlineMeeting = jResp:bool_of("isOnlineMeeting")
local onlineMeetingProvider = jResp:string_of("onlineMeetingProvider")
local isReminderOn = jResp:bool_of("isReminderOn")
local onlineMeetingJoinUrl = jResp:string_of("onlineMeeting.joinUrl")
local onlineMeetingConferenceId = jResp:string_of("onlineMeeting.conferenceId")
local onlineMeetingTollNumber = jResp:string_of("onlineMeeting.tollNumber")