APEX & Office 365 Calendar Integration

Search for a command to run...

Please kindly share the plugin as the QR code shared doesn't show anything anymore
thank you so muchJon Dixon
Another great post Jon, following your very clear guidance I was able to implement the MS Office 365 Calendar integration and learn a lot, thanks
In this series, I will cover integrating Oracle APEX with MS Office 365 Services such as Users, Calendars, SharePoint, and Email.
Introduction This blog post is the first in a series covering integrations between Oracle APEX and Microsoft Office 365. These integrations are made possible using Microsoft Graph APIs. Being able to integrate with Office 365 opens up a world of poss...
Introduction One of the marquee features of APEX 26.1 was AI Interactive Reports. When I started testing this new feature, I was interested to see what was going on behind the scenes. In this post, I

Introduction One of the marquee features of APEX 26.1 is APEX AI Agents. APEX AI Agents allow you to use an LLM and your own PL/SQL and JS tools to perform actions on your data instead of just chattin

Introduction In my previous post, I looked at logging APEX AI Agent requests and responses with Request and Response handlers. Logging is the first step because it shows you what is actually moving th

Introduction Logging is one of the first things you need when building serious AI Agents. Without it, debugging quickly becomes guesswork. You can see the final answer, but not always why the model ch

Context management patterns from building agents in Oracle APEX

In my previous post, I described how to configure an Azure AD App registration to facilitate access to the Microsoft Graph APIs. I also showed you how to call an MS Graph API from Postman and create an APEX Web Credential to access MS Graph APIs from Oracle APEX.
In this post, I will build on that knowledge and provide steps to build an integration between APEX and the Office 365 calendar using the calendar resource. We will create an APEX Calendar Region that directly sources its calendar entries from an Office 365 calendar. This integration is a great way to see someone's availability instantly from an APEX App.
Oh, and did I mention it will only require two lines of code?
Here is a YouTube clip that contains a sneak peek into what the finished calendar will look like. The users and calendar entries are coming directly from Office 365.
There are many other calendar-related MS Graph APIs available that enable you to do the following directly from an APEX App:
Follow the steps from my APEX & Office 365 Integration - Introduction post to see how to create an AD App registration using 'Microsoft Entra'. Once you have an App registration, complete the following steps from within the AD App registration:


Calendars.Read, then click 'Add permissions'


Calendars.Read permission

The first step is to test calling the Calendar Graph APIs from Postman.
Please refer to my APEX & Office 365 Integration - Introduction post for details on obtaining an MS Graph token using Postman. The token returned from this step will be used as a Bearer Token in the following steps.
📖 Documentation for the calendar Graph API can be found here.
An MS Office user could have more than one calendar, in which case, you can get a list of all their calendars using the list calendars resource.
For my example, I will get events for a user's default calendar. To identify which user's calendar, we can use their user id or their userPrincipalName (typically their email address). Refer to this post to get a list of users (including their id or their userPrincipalName) for your MS office 365 Tenant.
The Endpoint URL for the calendar events API is:
GET /users/{id | userPrincipalName}/calendar/events
e.g. https://graph.microsoft.com/v1.0/users/jon@cloudnueva.com/calendar/events
The screenshot below shows what the Parameters section looks like in Postman.
$filter parameter and to select which columns you want to be returned via the $select parameter.
In this screenshot, we see the MS Graph API token being passed as a 'Bearer Token'
In this screenshot, we see the HTTP headers. The Prefer header indicates that I want the dates and times for calendar entries to come back in the 'Pacific Standard Time' timezone. If you do not provide a value, dates and times will be returned in the 'UTC' timezone.

Here is a link to a sample response that includes all available fields.
Now that we understand how the Graph API works, it is time to integrate it with APEX. We are going to use APEX REST Sources to do the heavy lifting. If you need more control, you can use APEX_WEB_SERVICE to get the JSON response and use PL/SQL to parse and process it.
This post will focus on creating a REST Data Source to get calendar entries for a user's default calendar.
Refer to the demo application available from my GitHub Repository for the complete code.❗When you install the demo application, you will be prompted with the following:

<YOUR_MS_OFFICE_TENANT_ID> to your Microsoft Tenant ID.You will also need to update the column option_value for the option_code = TENANT_ID in the table 'CN_MS_GRAPH_OPTS' to your MS Office 365 Tenant ID.
If you do not already have a Web Credential created from the first post, you will need to create one now. ❗The Web Credential must refer to an MS Azure AD App registration with the Calendars.Read permission described above.
Follow these steps to create a REST Data Source which fetches calendar entries for a given user's default calendar.
https://graph.microsoft.com/v1.0/users/:user_id/calendar/events.:user_Id, which we will use the inject the id of the user whose calendar we want to view.userPrincipalName in this variable. While creating the REST source I entered a default value of my email address.
https://login.microsoftonline.com/<TENANT_ID>/oauth2/v2.0/token. Where <TENANT_ID> is your MS Office 365 Tenant ID
items to value



end.dateTime and start.dateTime. Doing this will make finding these columns easier when we create the APEX Calendar Region

user_id parameter to be required, and add the two additional Parameters $filter and $select as shown in the below screenshot

That completes the setup of the REST Data Source.
The final step is to create a calendar region that uses the REST Data Source to fetch the calendar entries from MS Office.
$filter and user_id should be displayed automatically


P5_USER_ID and P5_START_DT



In this post, I showed you how to integrate Office 365 calendar entries into an Oracle APEX Calendar region with just two lines of code. I encourage you to explore further and begin integrating Office 365 services into your APEX applications.