I wanted to get the list of booking businesses. I have the code working fwith Microsoft.Identity.Web.MicrosoftGraph so I decided to try with GraphBeta.
When calling Booking businesses from the graph service client I get the following error : Resource not found for the segment 'bookingBusinesses'
This is the line of code getting the error :
var bookingBusinesses = _graphServiceClient.BookingBusinesses.Request().GetAsync().Result;
Reproduction steps
Create a new project ASP.NET Core Web App ( Model-View-Controller) - Framework .NET 7.0 - Authentication type : Microsoft identity platform
Configure the project to connect Azure Ad ( App registration, fill appsettings.json)
Install Microsoft.Identity.Web and Microsoft.Identity.Web.MicrosoftGraphBeta
Configure Program.cs
string[]? initialScopes = builder.Configuration.GetValue<string>("Graph:Scopes")?.Split(' '); // Add services to the container. builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) .AddMicrosoftGraph(builder.Configuration.GetSection("Graph)) .AddInMemoryTokenCaches();
Add code to Index() of Home controller
[AuthorizeForScopes(Scopes = new[] { "Bookings.Read.All" })] public IActionResult Index() { var bookingBusinesses = _graphServiceClient.BookingBusinesses.Request().GetAsync().Result; // It fails here return View(); }
Error message
System.AggregateException: 'One or more errors occurred. (Code: BadRequest
Message: Resource not found for the segment 'bookingBusinesses'.
One or more errors occurred. (Code: BadRequest
Message: Resource not found for the segment 'bookingBusinesses'.
Inner error:
AdditionalData:
date: 2023-03-17T15:32:49
request-id: 75886252-5534-4123-881d-b52b26ebc5e5
client-request-id: 75886252-5534-4123-881d-b52b26ebc5e5
ClientRequestId: 75886252-5534-4123-881d-b52b26ebc5e5
)
Inner Exception Message
Code: BadRequest
Message: Resource not found for the segment 'bookingBusinesses'.
Inner error:
AdditionalData:
date: 2023-03-17T15:32:49
request-id: 75886252-5534-4123-881d-b52b26ebc5e5
client-request-id: 75886252-5534-4123-881d-b52b26ebc5e5
ClientRequestId: 75886252-5534-4123-881d-b52b26ebc5e5
Id Web logs
No response
Relevant code snippets
var bookingBusinesses = _graphServiceClient.BookingBusinesses.Request().GetAsync().Result;
Microsoft.Identity.Web Library
Microsoft.Identity.Web.GraphBeta
Microsoft.Identity.Web version
2.5.0
Web app
Sign-in users
Web API
Protected web APIs (validating tokens)
Token cache serialization
In-memory caches
Description
I wanted to get the list of booking businesses. I have the code working fwith Microsoft.Identity.Web.MicrosoftGraph so I decided to try with GraphBeta.
When calling Booking businesses from the graph service client I get the following error : Resource not found for the segment 'bookingBusinesses'
This is the line of code getting the error : var bookingBusinesses = _graphServiceClient.BookingBusinesses.Request().GetAsync().Result;
Reproduction steps
string[]? initialScopes = builder.Configuration.GetValue<string>("Graph:Scopes")?.Split(' '); // Add services to the container. builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) .AddMicrosoftGraph(builder.Configuration.GetSection("Graph)) .AddInMemoryTokenCaches();
private readonly ILogger<HomeController> _logger; private readonly GraphServiceClient _graphServiceClient; public HomeController(ILogger<HomeController> logger,GraphServiceClient graphServiceClient) { _logger = logger; _graphServiceClient = graphServiceClient; }
[AuthorizeForScopes(Scopes = new[] { "Bookings.Read.All" })] public IActionResult Index() { var bookingBusinesses = _graphServiceClient.BookingBusinesses.Request().GetAsync().Result; // It fails here return View(); }
Error message
System.AggregateException: 'One or more errors occurred. (Code: BadRequest Message: Resource not found for the segment 'bookingBusinesses'.
One or more errors occurred. (Code: BadRequest Message: Resource not found for the segment 'bookingBusinesses'. Inner error: AdditionalData: date: 2023-03-17T15:32:49 request-id: 75886252-5534-4123-881d-b52b26ebc5e5 client-request-id: 75886252-5534-4123-881d-b52b26ebc5e5 ClientRequestId: 75886252-5534-4123-881d-b52b26ebc5e5 )
Inner Exception Message
Code: BadRequest Message: Resource not found for the segment 'bookingBusinesses'. Inner error: AdditionalData: date: 2023-03-17T15:32:49 request-id: 75886252-5534-4123-881d-b52b26ebc5e5 client-request-id: 75886252-5534-4123-881d-b52b26ebc5e5 ClientRequestId: 75886252-5534-4123-881d-b52b26ebc5e5
Id Web logs
No response
Relevant code snippets
Regression
No response
Expected behavior
I expect to get the list of booking businesses