Forum Discussion
REST with Reports Fine with Groups 403 Forbidden Error
- 9 years ago
So I've managed to figure this out and the answer is "Permissions"
When originally following the tutorial for the 'Integrate Report Web App' that when you register teh application in the Azure AD to get your 'Client ID' and 'Client Secret' to tick some boxes
So notice that the "Read All Groups" box isn't ticked.
So I've gone back and registered the app this time with all boxes ticked
After updating the 'Client ID' and 'Client Secret' in my code I can now read the list of groups with the endpoint:
https://api.powerbi.com/v1.0/myorg/Groups
Hi Eric_Zhang
Thanks for the reply.
Yes I can get get the reports from a group with the Group ID as per your example endpoint
https://api.powerbi.com/v1.0/myorg/Groups/{groupid}/Reports
However the Power BI API says I should be able to get a list of groups with the following
https://api.powerbi.com/v1.0/myorg/Groups
I've tried the example code provided by the "Power BI API" site
using System; using System.Net.Http; var baseAddress = new Uri("https://api.powerbi.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("authorization", "Bearer tokenString"); using(var response = await httpClient.GetAsync("v1.0/myorg/groups")) { string responseData = await response.Content.ReadAsStringAsync(); }
However I get an error for the authentication about needing to supply the client secret which I'm currently trying to work out how to provide in a console app.
It seems that installing the NuGet Package using the following as per the instructions on Power BI Developer site at the bottom
Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory
Then gives an compile issue that the AuthenticationContext class doesn't contain a method called AcquireToken. This means that the code from the Power BI Developer Site needs updating to show how to include the 'Client Secret'.
I can't seem to find a working code example to authenticate with the latest packages and get a list of the Groups.
Thats the difficulties of my morning Eric hows yours going?
So I've managed to figure this out and the answer is "Permissions"
When originally following the tutorial for the 'Integrate Report Web App' that when you register teh application in the Azure AD to get your 'Client ID' and 'Client Secret' to tick some boxes
So notice that the "Read All Groups" box isn't ticked.
So I've gone back and registered the app this time with all boxes ticked
After updating the 'Client ID' and 'Client Secret' in my code I can now read the list of groups with the endpoint:
https://api.powerbi.com/v1.0/myorg/Groups