Closed leah-mq closed 1 year ago
Thanks for raising this @leah-mq
Any chance you can confirm the baseUrl used to configure the _graphServiceClient
? If the base url is the v1.0
you will run into the error.
For the beta pacakge, the base url would need to be https://graph.microsoft.com/v1.0/bookingBusinesses
Hello @andrueastman,
Thank you. I used the code that was working with the v1.0 and I kept the same baseUrl which is https://graph.microsoft.com/v1.0
I'll try with the base url provided and let you know my results.
Hello @andrueastman,
As you pointed out the baseurl, there was something wrong with it. I got it working using this one : https://graph.microsoft.com/beta/
Thank you for your help.
Describe the bug
I first opened this issue on the microsoft-identity-web repository and they told me to check here. ( see here for reference )
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;
To Reproduce 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("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 _logger; private readonly GraphServiceClient _graphServiceClient; public HomeController(ILogger logger,GraphServiceClient graphServiceClient) { _logger = logger; _graphServiceClient = graphServiceClient; }
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
Expected behavior
I expect to get the list of booking businesses
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context Add any other context about the problem here.