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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Operation returned an invalid status code 'NotFound' - PBI Embedded Token AppOwnsData

I have an issue getting the access token. 

 

I tried downloading the code from official link (https://github.com/microsoft/PowerBI-Developer-Samples) and made all necessary changes to the appsettings.json

 

appsettings.json

 

{
  "AzureAd": {
    "AuthenticationMode": "MasterUser",
    "AuthorityUri": "https://login.microsoftonline.com/organizations/",
    "ClientId": "<correct values have been specified>",
    "TenantId": "<correct values have been specified>",
    "Scope": [ "https://analysis.windows.net/powerbi/api/.default" ],
    "PbiUsername": "<correct values have been specified>",
    "PbiPassword": "<correct values have been specified>",
    "ClientSecret": ""
  },
  "PowerBI": {
    "WorkspaceId": "<correct values have been specified>",
    "ReportId": "<correct values have been specified>"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}

 

 

 

When I run the application I get this following error

 

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

at Microsoft.PowerBI.Api.EmbedTokenOperations.GenerateTokenWithHttpMessagesAsync(GenerateTokenRequestV2 requestParameters, Dictionary`2 customHeaders, CancellationToken cancellationToken)
at Microsoft.PowerBI.Api.EmbedTokenOperationsExtensions.GenerateTokenAsync(IEmbedTokenOperations operations, GenerateTokenRequestV2 requestParameters, CancellationToken cancellationToken)
at Microsoft.PowerBI.Api.EmbedTokenOperationsExtensions.GenerateToken(IEmbedTokenOperations operations, GenerateTokenRequestV2 requestParameters)
at AppOwnsData.Services.PbiEmbedService.GetEmbedToken(Guid reportId, IList`1 datasetIds, Guid targetWorkspaceId) in D:\Users\inflexion\Documents\IA Projects\Ebits\PowerBI-Developer-Samples-master\.NET Core\Embed for your customers\AppOwnsData\Services\PbiEmbedService.cs:line 150
at AppOwnsData.Services.PbiEmbedService.GetEmbedParams(Guid workspaceId, Guid reportId, Guid additionalDatasetId) in D:\Users\inflexion\Documents\IA Projects\Ebits\PowerBI-Developer-Samples-master\.NET Core\Embed for your customers\AppOwnsData\Services\PbiEmbedService.cs:line 69
at AppOwnsData.Controllers.EmbedInfoController.GetEmbedInfo() in D:\Users\inflexion\Documents\IA Projects\Ebits\PowerBI-Developer-Samples-master\.NET Core\Embed for your customers\AppOwnsData\Controllers\EmbedInfoController.cs:line 45

 

 

Looks like the error is rasied at below line of PbiEmbedService.cs file. This is part of GetEmbedToken function.

 

var embedToken = pbiClient.EmbedToken.GenerateToken(tokenRequest);

 

 

I am not sure what is causing this issue, looking for a solution to this.

 

Thanks & Regards,

Shahabaz Shafi  

 

 

Status: New
Comments
v-lili6-msft
Community Support

hi

please have a check if there is any permission problem in it.

 

Regards,

Lin

shahabazshafisk
Regular Visitor

@v-lili6-msft  When you say permission do you mean the one configured at the  Workspace and App Registration's API permissions? , they are configured fine. I am saying this because I have a working C# .NET application which uses Clients.ActiveDirectory method to generate token and its working fine, but this new app is throwing this error. 

shahabazshafisk
Regular Visitor

It was my mistake at the end. The report ID was bit old one thats why the app dint return any embed token.

tanisawakyo
New Member

hi

 

I have the same mistake,how to find "The report ID was bit old"? My report id was not change.

 

thank you