Calendars in Graph API

As part of my series of blog posts about Microsoft Graph, I’ll now look at Calendars and Events.

Microsoft Graph in Power Automate

In my series about Microsoft Graph you might want to have a look at

Calendars

Before jumping onto the HTTP request action, the Office 365 Outlook connector should also be considered. However, this connector is again quite limited with its actions available.

There is however also, the Send an HTTP request action in preview that may help with these gaps.

Calendar actions available within the Office 365 Outlook connector

List Calendars

For the List Calendars, it is possible to use the HTTP actions or the Send an HTTP request, however, the out of the box Get Calendars does exactly the same. So in this case avoiding the Graph API configuration steps, would be a waste of time in most cases.

Create Calendar

To create a new calendar you could use the following configuration:

Manage Calendars and Events using Microsoft Graph in Power Automate Microsoft Office 365, Microsoft Graph image 28

One important thing to notice here is that when you use the HTTP action with an app registration as authentication that you will get errors within /me however when you use this Send an HTTP request that doesn’t happen. This is because you have now authenticated with a connection rather than an app registration.

Once we run the above step the additional calendar will be created.

Manage Calendars and Events using Microsoft Graph in Power Automate Microsoft Office 365, Microsoft Graph image 27

Get Schedules

The Get Schedules is an interesting end point to use. By sending a POST request to https://graph.microsoft.com/v1.0/me/calendar/getSchedule it is possible to collect the events that have been scheduled for any specified set of people.

Manage Calendars and Events using Microsoft Graph in Power Automate Microsoft Office 365, Microsoft Graph image 29

The above could return something like the below json code, which can be used the schedule a meeting for all people involved.

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.scheduleInformation)",
  "value": [
    {
      "scheduleId": "pieter@pieterveenstramvp.onmicrosoft.com",
      "availabilityView": "000000000000000220000000000000000",
      "scheduleItems": [
        {
          "isPrivate": false,
          "status": "busy",
          "subject": "Focus time",
          "location": "",
          "isMeeting": false,
          "isRecurring": false,
          "isException": false,
          "isReminderSet": true,
          "start": {
            "dateTime": "2022-01-06T08:00:00.0000000",
            "timeZone": "UTC"
          },
          "end": {
            "dateTime": "2022-01-06T10:00:00.0000000",
            "timeZone": "UTC"
          }
        }
      ],
      "workingHours": {
        "daysOfWeek": [
          "monday",
          "tuesday",
          "wednesday",
          "thursday",
          "friday"
        ],
        "startTime": "08:00:00.0000000",
        "endTime": "17:00:00.0000000",
        "timeZone": {
          "name": "GMT Standard Time"
        }
      }
    },
    {
      "scheduleId": "lucy.eaver@pieterveenstramvp.onmicrosoft.com",
      "availabilityView": "000000000000000000000000000000000",
      "scheduleItems": [],
      "workingHours": {
        "daysOfWeek": [
          "monday",
          "tuesday",
          "wednesday",
          "thursday",
          "friday"
        ],
        "startTime": "08:00:00.0000000",
        "endTime": "17:00:00.0000000",
        "timeZone": {
          "name": "GMT Standard Time"
        }
      }
    }
  ]
}

Find Meeting Times

To find meeting times for a user you can use either https://graph.microsoft.com/v1.0/me/findMeetingTimes or https://graph.microsoft.com/v1.0/users/…/findMeetingTimes

There are however some problems on the way.

If we use the HTTP request action and use https://graph.microsoft.com/v1.0/me/findMeetingTimes we found earlier in my previous posts about user management using the graph api in Power Automate that there is no /me available, Also when we use the /users equivalent we will find that access to a person’s shared calendar is an issue.

Then when we try the existing connector we will find the following errors.

URI path is not a valid Graph endpoint, path is neither absolute nor relative or resource/object is not supported for this connector. Resources: me,users Objects: messages,mailFolders,events,calendar,calendars,outlook,inferenceClassification. Uri: https://graph.microsoft.com/v1.0/me/microsoft.graph.findMeetingTimes

Hmm, /findMeetingTimes is not available within this connector.

So what do we do?

We will have to create a custom connector. I will go into further details on how to create a custom connector in another post soon as it is a whole different subject.

Manage Calendars and Events using Microsoft Graph in Power Automate Microsoft Office 365, Microsoft Graph image 30

By specifying an action as shown above, we can create a flow with a custom action (and a connection!). In this example I haven’t cleaned up the custom connector at all. I will do this in a future post. At this point it is only important to be aware that this is the option to go for.

Manage Calendars and Events using Microsoft Graph in Power Automate Microsoft Office 365, Microsoft Graph image 31

So that we can get details as shown below.

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.meetingTimeSuggestionsResult",
  "emptySuggestionsReason": "",
  "meetingTimeSuggestions": [
    {
      "confidence": 100,
      "organizerAvailability": "free",
      "suggestionReason": "Suggested because it is one of the nearest times when all attendees are available.",
      "attendeeAvailability": [],
      "locations": [
        {
          "displayName": "Board room"
        }
      ],
      "meetingTimeSlot": {
        "start": {
          "dateTime": "2022-01-03T10:00:00.0000000",
          "timeZone": "UTC"
        },
        "end": {
          "dateTime": "2022-01-03T11:00:00.0000000",
          "timeZone": "UTC"
        }
      }
    },
    {
      "confidence": 100,
      "organizerAvailability": "free",
      "suggestionReason": "Suggested because it is one of the nearest times when all attendees are available.",
      "attendeeAvailability": [],
      "locations": [
        {
          "displayName": "Board room"
        }
      ],
      "meetingTimeSlot": {
        "start": {
          "dateTime": "2022-01-03T11:00:00.0000000",
          "timeZone": "UTC"
        },
        "end": {
          "dateTime": "2022-01-03T12:00:00.0000000",
          "timeZone": "UTC"
        }
      }
    },
    {
      "confidence": 100,
      "organizerAvailability": "free",
      "suggestionReason": "Suggested because it is one of the nearest times when all attendees are available.",
      "attendeeAvailability": [],
      "locations": [
        {
          "displayName": "Board room"
        }
      ],
      "meetingTimeSlot": {
        "start": {
          "dateTime": "2022-01-03T12:00:00.0000000",
          "timeZone": "UTC"
        },
        "end": {
          "dateTime": "2022-01-03T13:00:00.0000000",
          "timeZone": "UTC"
        }
      }
    },
    {
      "confidence": 100,
      "organizerAvailability": "free",
      "suggestionReason": "Suggested because it is one of the nearest times when all attendees are available.",
      "attendeeAvailability": [],
      "locations": [
        {
          "displayName": "Board room"
        }
      ],
      "meetingTimeSlot": {
        "start": {
          "dateTime": "2022-01-03T13:00:00.0000000",
          "timeZone": "UTC"
        },
        "end": {
          "dateTime": "2022-01-03T14:00:00.0000000",
          "timeZone": "UTC"
        }
      }
    },
    {
      "confidence": 100,
      "organizerAvailability": "free",
      "suggestionReason": "Suggested because it is one of the nearest times when all attendees are available.",
      "attendeeAvailability": [],
      "locations": [
        {
          "displayName": "Board room"
        }
      ],
      "meetingTimeSlot": {
        "start": {
          "dateTime": "2022-01-03T14:00:00.0000000",
          "timeZone": "UTC"
        },
        "end": {
          "dateTime": "2022-01-03T15:00:00.0000000",
          "timeZone": "UTC"
        }
      }
    }
  ]
}

So now we can use the Graph end point for getting options to organise our meeting that we want to schedule using our flows in Power Automate or apps in Power Apps.

Events

For quite a few of the end points related to events in calendars, you can use the Office 365 Outlook connector, however there are a few event operations available through the graph api that this connector doesn’t yet support.

The missing operations in this connector are:

  • Get Delta
  • Forward Event
  • Cancel Event
  • Accept Event
  • Tentatively Accept
  • Decline event
  • Dismiss reminder
  • Snooze reminder
  • List event instances
  • List attachments
  • Add attachment
  • Create session to attach large file
  • Create open extension
  • Get Open extension

For the above endpoints we can use the Send an HTTP request action available in the outlook connector. No need to use the HTTP action in this case.

Other Posts in this series

Introduction to using the Microsoft Graph API in the Power Platform

Manage Users using the Graph API in Power Automate

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

2 thoughts on “Manage Calendars and Events using Microsoft Graph in Power Automate”
  1. I am hoping you will follow up with this proposed article soon:

    “We will have to create a custom connector. I will go into further details on how to create a custom connector in another post soon as it is a whole different subject.”

    Thanks.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.