Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
I am trying to run sample report https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-sample-for-customers?tabs=net-cor... and getting error "Operation returned an invalid status code 'Unauthorized''" at var pbiReport = pbiClient.Reports.GetReportInGroup(workspaceId, reportId);
I gave the user account admin right to the workspace, report and dataset.
Can someone please help?
Thanks,
William.
Hi @WilliamTit ,
Whether your problem has been resolved? If yes, could you please mark the helpful post as Answered? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.
Best Regards
Hi @WilliamTit ,
If you are using service principal authentication, please check whether you have enabled "Allow service principals to use Power BI APIs" feature in Admin portal.
Also, has the service principal been added as member or admin of workspace?
And you can refer the following video to check if something is missing...
Embed Power BI Report for Customers using App Own Concept and Service Principal
Embed Power BI Report for Customers using App Owns Data and Master User
In addition, the followings are the ones which has similar problem with yours. Hope they can help you.
Operation returned an invalid status code 'Unauthorized''
Based on your description, I assumed that you are using the Access token for Power BI users (user owns data) approach. I would recommend you use https://jwt.io/ to decode the access_token after successfully invoked
authContext.AcquireTokenAsync
. Make sure theaud
ishttps://analysis.windows.net/powerbi/api
and check the permissions scope propertyscp
.For Get Groups, the required scope would look as follows:
Required scope: Group.Read.All or Group.ReadWrite.All or Workspace.Read.All or Workspace.ReadWrite.All
You could also use fiddler or postman to simulate the request against the get groups endpoint with the access_token received in your WPF application to narrow down this issue.
Moreover, you could follow Register an application to check your Azure AD app and make sure the required delegated permissions to Power BI Service (Microsoft.Azure.AnalysisServices) API have been correctly configured.
401 when accessing any Power BI API endpoints
I found something that work and documented it (with code) here: https://bitbucket.org/omnistream/powerbi-api-exampleHopefully it would help other people in need!
It's not entirely satisfying: I'm notably not too sure why I should use this authentication endpoint instead of the one I found in other documentation, nor why I have to use a username/password on top of the app credentials, especially since it's not a super secure way to do it; I'm concerned it may get deprecated in the future. But it works.
Best Regards
User | Count |
---|---|
9 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
11 | |
3 | |
2 | |
2 | |
2 |