Dart
Dart
Outlook Calendar List Events
See more Outlook Calendar Examples
Retrieve a list of events in a calendar.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final http = CkHttp();
// Use your previously obtained access token here: Get Outlook Calendar OAuth2 Access Token (Azure AD v2.0 Endpoint).
final jsonToken = CkJsonObject();
try {
jsonToken.loadFile('qa_data/tokens/outlookCalendar.json');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
http.authToken = jsonToken.stringOf('access_token');
// Specify the ID of the calendar to list.
final calendarId = 'AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5_vF7TKKdE6bGCRqXyl2PQAAAgEGAAAA5_vF7TKKdE6bGCRqXyl2PQAAAiCsAAAA';
http.setUrlVar('id', calendarId);
// To list the events in the default calendar, use the following URL: https://graph.microsoft.com/v1.0/me/calendars/events
final resp = CkHttpResponse();
try {
http.httpNoBody('GET', 'https://graph.microsoft.com/v1.0/me/calendars/{\$id}/events', resp);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print('Response status code = ${resp.statusCode}');
// The HTTP request succeeded if the response status code = 200.
if (resp.statusCode != 200) {
print(resp.bodyStr);
print('Failed');
return;
}
final json = CkJsonObject();
json.load(resp.bodyStr);
json.emitCompact = false;
print(json.emit());
// Here is a sample response:
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
// {
// "value": [
// {
// "originalStartTimeZone": "originalStartTimeZone-value",
// "originalEndTimeZone": "originalEndTimeZone-value",
// "responseStatus": {
// "response": "",
// "time": "datetime-value"
// },
// "iCalUId": "iCalUId-value",
// "reminderMinutesBeforeStart": 99,
// "isReminderOn": true
// }
// ]
// }
var originalStartTimeZone = '';
var originalEndTimeZone = '';
var responseStatusResponse = '';
var responseStatusTime = '';
var iCalUId = '';
var reminderMinutesBeforeStart = 0;
var i = 0;
final countI = json.sizeOfArray('value');
while (i < countI) {
json.i = i;
originalStartTimeZone = json.stringOf('value[i].originalStartTimeZone');
originalEndTimeZone = json.stringOf('value[i].originalEndTimeZone');
responseStatusResponse = json.stringOf('value[i].responseStatus.response');
responseStatusTime = json.stringOf('value[i].responseStatus.time');
iCalUId = json.stringOf('value[i].iCalUId');
reminderMinutesBeforeStart = json.intOf('value[i].reminderMinutesBeforeStart');
json.boolOf('value[i].isReminderOn');
i++;
}
}