How do I update "allowedOnlineMeetingProviders" for a azure AD user via the Microsoft Graph API?

matt 1 Reputation point
2021-11-05T06:46:49.787+00:00

When I go to create online meetings with users that don't have teamsForBusiness set in the allowedOnlineMeetingProviders property of the users calendar, it only creates events. How can I programmatically update this?

This is how I create the online meetings:

 // Create client  
 var graphServiceClient = CreateGraphClient();  
      
 // Build event  
 var newEvent = new Event()  
 {  
      Subject = subject,  
      Body = new ItemBody() { ContentType = BodyType.Text, Content = body },  
      Start = startDate,  
      End = endDate,  
      IsOnlineMeeting = true,  
      Attendees = attendees == null ? null : GetAttendees(attendees),  
      OnlineMeetingProvider = OnlineMeetingProviderType.TeamsForBusiness  
};  

Notice that [IsOnlineMeeting = true] and [OnlineMeetingProvider = OnlineMeetingProviderType.TeamsForBusiness] but in the response (below) [IsOnlineMeeting = false] and [OnlineMeetingProvider = OnlineMeetingProviderType.Unknown]

146620-image.png

In addition I can only seem to update this value by logging in as the user to Microsoft Teams (desktop or web app) AND after pressing create meeting now which is very odd.

Before the user is able to create online meetings, their calendar looks like below (allowedOnlineMeetingProviders is empty):

GET https://graph.microsoft.com/v1.0/users/{userId}/calendars  

{  
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('userId')/calendars",  
    "value": [  
        {  
            "id": "XYZ...",  
            "name": "Calendar",  
            "color": "auto",  
            "hexColor": "",  
            "isDefaultCalendar": true,  
            "changeKey": "xyz",  
            "canShare": true,  
            "canViewPrivateItems": true,  
            "canEdit": true,  
            "allowedOnlineMeetingProviders": [],  
            "defaultOnlineMeetingProvider": "unknown",  
            "isTallyingResponses": true,  
            "isRemovable": false,  
            "owner": {  
                "name": "Bill",  
                "address": "xyz@xyz.com"  
            }  
        }  
    ]  
}  

I would have thought you would be able to do it when you update the calendar but the only property available to update is the name using the call below:

PATCH /users/{id | userPrincipalName}/calendar  

link to the documentation: https://learn.microsoft.com/en-us/graph/api/calendar-update?view=graph-rest-1.0&tabs=csharp

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,716 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 37,456 Reputation points
    2021-11-05T09:44:29.417+00:00

    There seems to be a problem with the code you create the event, try this:

    using Microsoft.Graph;  
    using Microsoft.Graph.Auth;  
    using Microsoft.Identity.Client;  
    using Newtonsoft.Json;  
    using System;  
    using System.Collections.Generic;  
      
    namespace test  
      
    {  
        class Program  
        {  
      
            static async System.Threading.Tasks.Task Main(string[] args)  
      
            {  
                IConfidentialClientApplication app;  
                app = ConfidentialClientApplicationBuilder.Create("{client id}")  
                        .WithClientSecret("{client secret}")  
                        .WithAuthority(new Uri("https://login.microsoftonline.com/{tenant id}"))  
                        .Build();  
      
                AuthenticationResult result = null;  
                string[] scopes = new string[] { "https://graph.microsoft.com/.default" };  
                result = await app.AcquireTokenForClient(scopes).ExecuteAsync();  
                string accesstoken = result.AccessToken;  
      
                //Console.WriteLine(accesstoken);  
      
                ClientCredentialProvider authProvider = new ClientCredentialProvider(app);  
      
                GraphServiceClient graphClient = new GraphServiceClient(authProvider);  
      
                var @event = new Event  
                {  
                    Subject = "Let's go for lunch",  
                    Body = new ItemBody  
                    {  
                        ContentType = BodyType.Html,  
                        Content = "Does next month work for you?"  
                    },  
                    Start = new DateTimeTimeZone  
                    {  
                        DateTime = "2019-03-10T12:00:00",  
                        TimeZone = "Pacific Standard Time"  
                    },  
                    End = new DateTimeTimeZone  
                    {  
                        DateTime = "2019-03-10T14:00:00",  
                        TimeZone = "Pacific Standard Time"  
                    },  
                    Location = new Location  
                    {  
                        DisplayName = "Harry's Bar"  
                    },  
                    Attendees = new List<Attendee>()  
        {  
            new Attendee  
            {  
                EmailAddress = new EmailAddress  
                {  
                    Address = "adelev@contoso.onmicrosoft.com",  
                    Name = "Adele Vance"  
                },  
                Type = AttendeeType.Required  
            }  
        },  
                    IsOnlineMeeting = true,  
                    OnlineMeetingProvider = OnlineMeetingProviderType.TeamsForBusiness  
                };  
      
               await graphClient.Users["{user id}"].Calendars["{calendar id}"].Events  
                    .Request()  
                    .AddAsync(@event);  
        
            }  
        }  
    }  
    

    146845-350.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.