Episode #140 – Using Microsoft Graph to create Microsoft Teams online meetings

Here you can find the transcript of Episode #140 of PiaSys TechBites.

Welcome back to PiaSys Tech Bites. Today I want to show you how we can use the Microsoft Graph to create Online Meetings. And specifically, we have at least a couple of options to do that. One is to create an event in the Calendar, which can be, for example, a personal Calendar or a Microsoft Teams Calendar. And by doing that, you will be able to create a new Meeting, which will show up in the users’ Calendar, and which will be defined when the isOnlineMeeting flag has a value of true in order to make it an Online Meeting.

Another option is to use the Online Meetings collection of the me endpoint of every user in Microsoft 365. And by doing that, you will create a Meeting which will not show up in the Calendar of the users, but which will be, by default and only in Online Meeting. And you will get back as JSON result all of the information about the Meeting, including the join URL, for example. And you can help yourself processing JSON response and using that information you will get back in order to notify the users about the Meeting and the join URL for the Meeting. Whenever you use the second option, you have to provide the unique id from an Azure Active Directory point of view of the user who is the organizer of the Meeting.

So, like always, let me move to the demo environment and let me show you how to do that in practice. So here you see the documentation of the first option, the Create Event option, which is available in order to create a Calendar event in the current user Calendar, using the me/events or in the specific user Calendar or event in the Calendar of a team.

In order to do that from a delegated point of view, you need the Calendar.ReadWrite permission as well as for the application only point of view. When you make such a request you can provide and you have to provide the event object as the input and in the event object, you will have a bunch of properties that you can specify, including for example, the list of attendees, the body of the Meeting request, the subject of the Meeting, the start and the end of the Meeting in the Calendar, as well as you will find the isOnlineMeeting boolean flag to specify if the Meeting is an online one.

So if we go to Graph Explorer, we can, for example, make a request targeting the collection of events of my currently connected user. I can make a post request. I will have to specify the content as a JSON content. So I will have to specify the content-type of my request as application/json and I will add it to the list of headers. In the request body, I can provide a JSON request like the following one where I specify the subject of the Meeting, the body of the Meeting, the start, and then date and time with the time zone, a location, which will be Microsoft Teams, but this is just a description. Then the list of attendees and I can invite myself to this Meeting. It will be an Online Meeting. I can allow a new time proposal from the invited attendees, and I can also provide a unique id, which is called transactionId to avoid creating duplicates of the same request if we will, by accident send the same request multiple times to the target Microsoft Graph API. Using this unique id, which is optional Microsoft Graph will understand that it is a repeated request and it will not create another Meeting. So if I execute these requests, you see it will take a few seconds. And then I will get back as a response the JSON of the Meeting that was created. And if I go to my Calendar, I can see that I have a new Meeting in my Calendar on the 12th of February, from 12:00 PM to 2:00 PM, which is exactly what I defined in my request, when I created the Meeting.

Another option is to use the Create Online Meeting endpoint that which is available under the me endpoint of every user. And so for the currently connected user, you can access the collection of Online Meetings. You can make a post and you can provide in the request some information about the Online Meeting object that you want to create.

And again, enter the Online Meeting is made of a bunch of properties, which you can specify to describe the Meeting you want to create. In order to do that, you will need from an authorization point of view, from a delegated point of view, the OnlineMeetings.ReadWrite Permission, and this is not supported in application only mode. So if I go back to Microsoft Graph, I can target the endpoint for my Online Meetings for my currently connected user and in the body of the request, which will still be a JSON request. So we still need to have the request either with content type application JSON, I specify the start and end time, the subject, if can allow the presenters only as the organizer I need. This is a requirement to define the list of participants. And specifically you have to specify the organizer, providing the unique id in Azure Active Directory of the user, which is an information you can get by equating the me and point with the get.

And then I can specify the attendees of the Meeting as a list of a user principal names with their role, so presenter or attendee. By doing that again, let me run this request. I will get back JSON response, which will include all of the details of my Meeting, including the join URL and the join web URL, which I can use to provide this information to the users or to save this information in a custom application of my own. So simple as that.

Like always, thank you for watching this video. I hope you found it interesting, and I’m really looking forward to seeing you next week and remember to subscribe to this channel. Thank you.