Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
saivina2920
Post Prodigy
Post Prodigy

Operation returned an invalid status code 'Unauthorized' while connecting Power BI embed app.

I am getting error in the below line while connecting Power BI with embed app.

 

I have give all id's in JSON settings like below.

 

"AzureAd": {
"AuthenticationMode": "ServicePrincipal",
//"AuthorityUrl": "https://login.microsoftonline.com/organizations/",
"AuthorityUrl": "https://login.microsoftonline.com/que8ad7-adsd-w22sf-23iuhsasd",
"ClientId": "fdsguy-erhdj-rtyuiw-32987ud-fdwiu8ds7s",
"TenantId": "8fdf987ad87-dsafi-ytrt5-niuwoiuafm09er9",
"ScopeBase": [ "https://analysis.windows.net/powerbi/api/.default" ],
"PbiUsername": "comp1@tek.com",
"PbiPassword": "************",
"ClientSecret": "fdsgshfgajdad-dafdbvnvfoiepi-3edfsfdshj"
},
"PowerBI": {
"WorkspaceId": "4398dsewwsdfkg-fdijo-hoigu-kjfdj-irkfjfjdsa0w987e",
"ReportId": "fvxcn-cvkbvj-vcxbivc-vcxbj-er9rekjxlj",
"DataSetId": "hfakjfdadaf-adsfljjreuu8-fdld87fsf-fsghfkfs"

 

 

But, still i am getting  below error.

 

Error Details:
Operation returned an invalid status code 'Unauthorized'

at Microsoft.PowerBI.Api.ReportsOperations.GetReportInGroupWithHttpMessagesAsync(Guid groupId, Guid reportId, Dictionary`2 customHeaders, CancellationToken cancellationToken)
at Microsoft.PowerBI.Api.ReportsOperationsExtensions.GetReportInGroupAsync(IReportsOperations operations, Guid groupId, Guid reportId, CancellationToken cancellationToken)
at Microsoft.PowerBI.Api.ReportsOperationsExtensions.GetReportInGroup(IReportsOperations operations, Guid groupId, Guid reportId)
at AppOwnsData.Services.PbiEmbedService.GetEmbedParams(Guid workspaceId, Guid reportId, Guid additionalDatasetId) in C:\Users\PowerBI-Developer-Samples-master\.NET Core\Embed for your customers\AppOwnsData\Services\PbiEmbedService.cs:line 46
at AppOwnsData.Controllers.EmbedInfoController.GetEmbedInfo() in C:\Users\PowerBI-Developer-Samples-master\.NET Core\Embed for your customers\AppOwnsData\Controllers\EmbedInfoController.cs:line 45

 

below is my code

 

public PowerBIClient GetPowerBIClient()
{
var tokenCredentials = new TokenCredentials(aadService.GetAccessToken(), "Bearer");
return new PowerBIClient(new Uri(powerBiApiUrl ), tokenCredentials);
}

 

Error line

*******************

PowerBIClient pbiClient = this.GetPowerBIClient();

// Get report info
var pbiReport = pbiClient.Reports.GetReportInGroup(workspaceId, reportId); ==> Error Line

 

What is the error and how we could solve this....?

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @saivina2920 ,

 

Could it be permission issue?

The account must be the admin of the related workspaces when you need to embeded report in the application.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

10 REPLIES 10
MRIZ
Helper II
Helper II

Hi you got any solution. I am stuck in same issue!

same issue too, do you have any solution

Hi, yes this issue was resolved for me. I did different things i am forgetting it, I guess I was forgetting to give admin access to my Service Pricncipal on my WorkSpace is Worspace Access option.

thanks. But i have done this

OneDriveAppOwnsData.sln

this is running project for your reference. May be it can help you!!

 

thanks, this is only the sln file, maybe you miss some others. And I want to know if you use the service principle to add or update data to powerBI, I can access to getworkspace, but fialed when try to upload new report, meet the 'unauthorized', I think maybe it is read-only?

bingo_0-1703666363580.png

 

Sorry for inconvinience, PFB updated link
Check if this runs for you or not after replacing all the values in json
Embed for your customers.rar

v-jayw-msft
Community Support
Community Support

Hi @saivina2920 ,

 

Could it be permission issue?

The account must be the admin of the related workspaces when you need to embeded report in the application.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

Yes. It's great.

saivina2920
Post Prodigy
Post Prodigy

Anyone can update relate this issue pls..

 

This is very very urgent.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors