I am trying to create virtual appointments based on this documentation:
https://learn.microsoft.com/en-us/graph/api/application-post-onlinemeetings?view=graph-rest-1.0&tabs=csharp
Here is my code:
InteractiveBrowserCredentialOptions options = new()
{
TenantId = B2CConstants.TenantId,
ClientId = B2CConstants.ClientId,
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
// MUST be http://localhost or http://localhost:PORT
// See https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/System-Browser-on-.Net-Core
RedirectUri = new Uri("http://localhost"),
};
// https://learn.microsoft.com/dotnet/api/azure.identity.interactivebrowsercredential
var interactiveCredential = new InteractiveBrowserCredential(options);
GraphServiceClient graphClient = new(interactiveCredential, B2CConstants.Scopes);
var onlineMeeting = new OnlineMeeting
{
StartDateTime = DateTimeOffset.Parse("2023-02-17T18:00:34.2444915+00:00"),
EndDateTime = DateTimeOffset.Parse("2023-02-17T18:30:34.2464912+00:00"),
ExternalId = Guid.NewGuid().ToString(),
Subject = "User Token Meeting"
};
try
{
await graphClient.Me.OnlineMeetings
.Request()
.AddAsync(onlineMeeting);
}
catch (Exception ex)
{
}
AddAsync() throws an exception:
{Status Code: 0
Microsoft.Graph.ServiceException: Code: generalException
Message: An error occurred sending the request.
---> System.TypeLoadException: Could not load type of field 'Microsoft.Graph.TokenCredentialAuthProvider+<AuthenticateRequestAsync>d__3:<>u__1' (4) due to: Could not resolve type with token 01000021 from typeref (expected class 'System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1' in assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e') assembly:mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e type:System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1 member:(null)
at Microsoft.Graph.AuthenticationHandler.SendAsync(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at Microsoft.Graph.HttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Microsoft.Graph.HttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.Graph.HttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at Microsoft.Graph.BaseRequest.<SendAsync>d__34`1[[Microsoft.Graph.OnlineMeeting, Microsoft.Graph, Version=4.49.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()
at LATICRETE_MobileApp.Features.VideoChat.VideoChatPageModel.CreateMeetingAsync() in C:\Git Repos\LATICRETE Mobile App\LATICRETE_MobileApp\Features\VideoChat\VideoChatPageModel.cs:line 139}
Could you please explain what I am missing?