Xbase++
Xbase++
MS Graph Calendar List Events
See more Microsoft Calendar Examples
Retrieve a list of events in a calendar. The list contains single instance meetings and series masters.For more details, see https://docs.microsoft.com/en-us/graph/api/calendar-list-events?view=graph-rest-1.0
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oJsonToken
LOCAL cStrResponse
LOCAL oJson
LOCAL cOdataContext
LOCAL i
LOCAL nCount_i
LOCAL cOdataEtag
LOCAL cId
LOCAL cCreatedDateTime
LOCAL cLastModifiedDateTime
LOCAL cChangeKey
LOCAL cOriginalStartTimeZone
LOCAL cOriginalEndTimeZone
LOCAL cICalUId
LOCAL nReminderMinutesBeforeStart
LOCAL nIsReminderOn
LOCAL nHasAttachments
LOCAL cSubject
LOCAL cBodyPreview
LOCAL cImportance
LOCAL cSensitivity
LOCAL nIsAllDay
LOCAL nIsCancelled
LOCAL nIsOrganizer
LOCAL nResponseRequested
LOCAL cSeriesMasterId
LOCAL cShowAs
LOCAL cV_type
LOCAL cWebLink
LOCAL cOnlineMeetingUrl
LOCAL cRecurrence
LOCAL cResponseStatusResponse
LOCAL cResponseStatusTime
LOCAL cBodyContentType
LOCAL cBodyContent
LOCAL cStartDateTime
LOCAL cStartTimeZone
LOCAL cEndDateTime
LOCAL cEndTimeZone
LOCAL cLocationDisplayName
LOCAL cLocationLocationType
LOCAL cLocationUniqueId
LOCAL cLocationUniqueIdType
LOCAL cOrganizerEmailAddressName
LOCAL cOrganizerEmailAddressAddress
LOCAL j
LOCAL nCount_j
LOCAL cDisplayName
LOCAL cLocationType
LOCAL cUniqueId
LOCAL cUniqueIdType
LOCAL cStatusResponse
LOCAL cStatusTime
LOCAL cEmailAddressName
LOCAL cEmailAddressAddress
nSuccess := 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oHttp := CreateObject("Chilkat.Http")
// Use your previously obtained access token as shown here:
// Get Microsoft Graph OAuth2 Access Token with Calendars.ReadWrite scope.
oJsonToken := CreateObject("Chilkat.JsonObject")
nSuccess := oJsonToken:LoadFile("qa_data/tokens/msGraphCalendar.json")
IF (nSuccess == 0)
? oJsonToken:LastErrorText
oHttp:destroy()
oJsonToken:destroy()
RETURN
ENDIF
oHttp:AuthToken := oJsonToken:StringOf("access_token")
// Specify the calendar id
oHttp:SetUrlVar("id", "AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5_vF7TKKdE6bGCRqXyl2PQAAAgEGAAAA5_vF7TKKdE6bGCRqXyl2PQAClEpRTgAAAA==")
// Send a GET request to https://graph.microsoft.com/v1.0/me/calendars/{$id}/events
cStrResponse := oHttp:QuickGetStr("https://graph.microsoft.com/v1.0/me/calendars/{$id}/events")
IF (oHttp:LastMethodSuccess == 0)
? oHttp:LastErrorText
oHttp:destroy()
oJsonToken:destroy()
RETURN
ENDIF
oJson := CreateObject("Chilkat.JsonObject")
oJson:Load(cStrResponse)
oJson:EmitCompact := 0
IF (oHttp:LastStatus != 200)
? oJson:Emit()
? "Failed, response status code = " + Str(oHttp:LastStatus)
oHttp:destroy()
oJsonToken:destroy()
oJson:destroy()
RETURN
ENDIF
? oJson:Emit()
// Sample output:
// (See parsing code below..)
// {
// "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('admin%40chilkat.io')/calendars('AQMkADAwATM0MDAAMS1i ... AClEpRTgAAAA%3D%3D')/events",
// "value": [
// {
// "@odata.etag": "W/\"5+vF7TKKdE6bGCRqXyl2PQAClIgmmw==\"",
// "id": "AQMkADAwATM0MDAAM ... AApRZ7JkAAAA=",
// "createdDateTime": "2019-04-26T14:31:39.8791929Z",
// "lastModifiedDateTime": "2019-04-26T14:31:41.2753537Z",
// "changeKey": "5+vF7TKKdE6bGCRqXyl2PQAClIgmmw==",
// "categories": [
// ],
// "originalStartTimeZone": "Pacific Standard Time",
// "originalEndTimeZone": "Pacific Standard Time",
// "iCalUId": "040000008200E ... A230FEBFE5F7486A",
// "reminderMinutesBeforeStart": 15,
// "isReminderOn": true,
// "hasAttachments": false,
// "subject": "Let's go for lunch",
// "bodyPreview": "Does mid month work for you?",
// "importance": "normal",
// "sensitivity": "normal",
// "isAllDay": false,
// "isCancelled": false,
// "isOrganizer": true,
// "responseRequested": true,
// "seriesMasterId": null,
// "showAs": "busy",
// "type": "singleInstance",
// "webLink": "https://outlook.live.com/owa/?itemid=AQMkADAwATM0MDAAMS1iNTcwLWI2NT ... gkal8pdj0AApRZ7JkAAAA%3D&exvsurl=1&path=/calendar/item",
// "onlineMeetingUrl": null,
// "recurrence": null,
// "responseStatus": {
// "response": "organizer",
// "time": "0001-01-01T00:00:00Z"
// },
// "body": {
// "contentType": "html",
// "content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nDoes mid month work for you?\r\n</body>\r\n</html>\r\n"
// },
// "start": {
// "dateTime": "2019-11-15T20:00:00.0000000",
// "timeZone": "UTC"
// },
// "end": {
// "dateTime": "2019-11-15T22:00:00.0000000",
// "timeZone": "UTC"
// },
// "location": {
// "displayName": "Harry's Bar",
// "locationType": "default",
// "uniqueId": "Harry's Bar",
// "uniqueIdType": "private"
// },
// "locations": [
// {
// "displayName": "Harry's Bar",
// "locationType": "default",
// "uniqueId": "Harry's Bar",
// "uniqueIdType": "private"
// }
// ],
// "attendees": [
// {
// "type": "required",
// "status": {
// "response": "none",
// "time": "0001-01-01T00:00:00Z"
// },
// "emailAddress": {
// "name": "Adele Vance",
// "address": "adelev@contoso.onmicrosoft.com"
// }
// }
// ],
// "organizer": {
// "emailAddress": {
// "name": "Matt",
// "address": "outlook_3A33FCEB9B74CC15@outlook.com"
// }
// }
// }
// ]
// }
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
cOdataContext := oJson:StringOf('"@odata.context"')
i := 0
nCount_i := oJson:SizeOfArray("value")
DO WHILE i < nCount_i
oJson:I := i
cOdataEtag := oJson:StringOf('value[i]."@odata.etag"')
cId := oJson:StringOf("value[i].id")
cCreatedDateTime := oJson:StringOf("value[i].createdDateTime")
cLastModifiedDateTime := oJson:StringOf("value[i].lastModifiedDateTime")
cChangeKey := oJson:StringOf("value[i].changeKey")
cOriginalStartTimeZone := oJson:StringOf("value[i].originalStartTimeZone")
cOriginalEndTimeZone := oJson:StringOf("value[i].originalEndTimeZone")
cICalUId := oJson:StringOf("value[i].iCalUId")
nReminderMinutesBeforeStart := oJson:IntOf("value[i].reminderMinutesBeforeStart")
nIsReminderOn := oJson:BoolOf("value[i].isReminderOn")
nHasAttachments := oJson:BoolOf("value[i].hasAttachments")
cSubject := oJson:StringOf("value[i].subject")
cBodyPreview := oJson:StringOf("value[i].bodyPreview")
cImportance := oJson:StringOf("value[i].importance")
cSensitivity := oJson:StringOf("value[i].sensitivity")
nIsAllDay := oJson:BoolOf("value[i].isAllDay")
nIsCancelled := oJson:BoolOf("value[i].isCancelled")
nIsOrganizer := oJson:BoolOf("value[i].isOrganizer")
nResponseRequested := oJson:BoolOf("value[i].responseRequested")
cSeriesMasterId := oJson:StringOf("value[i].seriesMasterId")
cShowAs := oJson:StringOf("value[i].showAs")
cV_type := oJson:StringOf("value[i].type")
cWebLink := oJson:StringOf("value[i].webLink")
cOnlineMeetingUrl := oJson:StringOf("value[i].onlineMeetingUrl")
cRecurrence := oJson:StringOf("value[i].recurrence")
cResponseStatusResponse := oJson:StringOf("value[i].responseStatus.response")
cResponseStatusTime := oJson:StringOf("value[i].responseStatus.time")
cBodyContentType := oJson:StringOf("value[i].body.contentType")
cBodyContent := oJson:StringOf("value[i].body.content")
cStartDateTime := oJson:StringOf("value[i].start.dateTime")
cStartTimeZone := oJson:StringOf("value[i].start.timeZone")
cEndDateTime := oJson:StringOf("value[i].end.dateTime")
cEndTimeZone := oJson:StringOf("value[i].end.timeZone")
cLocationDisplayName := oJson:StringOf("value[i].location.displayName")
cLocationLocationType := oJson:StringOf("value[i].location.locationType")
cLocationUniqueId := oJson:StringOf("value[i].location.uniqueId")
cLocationUniqueIdType := oJson:StringOf("value[i].location.uniqueIdType")
cOrganizerEmailAddressName := oJson:StringOf("value[i].organizer.emailAddress.name")
cOrganizerEmailAddressAddress := oJson:StringOf("value[i].organizer.emailAddress.address")
j := 0
nCount_j := oJson:SizeOfArray("value[i].categories")
DO WHILE j < nCount_j
oJson:J := j
// ...
j := j + 1
ENDDO
j := 0
nCount_j := oJson:SizeOfArray("value[i].locations")
DO WHILE j < nCount_j
oJson:J := j
cDisplayName := oJson:StringOf("value[i].locations[j].displayName")
cLocationType := oJson:StringOf("value[i].locations[j].locationType")
cUniqueId := oJson:StringOf("value[i].locations[j].uniqueId")
cUniqueIdType := oJson:StringOf("value[i].locations[j].uniqueIdType")
j := j + 1
ENDDO
j := 0
nCount_j := oJson:SizeOfArray("value[i].attendees")
DO WHILE j < nCount_j
oJson:J := j
cV_type := oJson:StringOf("value[i].attendees[j].type")
cStatusResponse := oJson:StringOf("value[i].attendees[j].status.response")
cStatusTime := oJson:StringOf("value[i].attendees[j].status.time")
cEmailAddressName := oJson:StringOf("value[i].attendees[j].emailAddress.name")
cEmailAddressAddress := oJson:StringOf("value[i].attendees[j].emailAddress.address")
j := j + 1
ENDDO
i := i + 1
ENDDO
? "Success."
oHttp:destroy()
oJsonToken:destroy()
oJson:destroy()