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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Not applicable

Error:500 BadRequest when trying to get embed token of new reports

I created an api that uses Service Principal to connect to AAD and generate embed tokens, and sends that token to my frontend. It is working well when I use old reports that some of my colleages published last summer, however, we are trying to use Azure Analysis Services and created some new reports to test it.

The api isn't able to generate the embed tokens for these new reports, throwing instead a BadRequest 500. Also while I was figuring out RLS I published another report from a sample given by Microsoft and the same BadRequest happens for the sample report. Are we forgetting some kind of configuration needed to generate tokens? I understand the erros with the reports using AAS but the one I published does not use it afaik.


Here is my code:


private static readonly string Tenant = "tenant";
private static readonly string AppId = "id";
private static readonly string AppSecret = "secret";
private static readonly string Resource = "";

private string getToken()
var authContext = new AuthenticationContext(Tenant);
var clientCredential = new ClientCredential(AppId, AppSecret);
return authContext.AcquireTokenAsync(Resource, clientCredential).Result.AccessToken;

private PowerBIClient getPBIClient()
var token = new TokenCredentials(getToken(), "Bearer");
return new PowerBIClient(new Uri(""), token);

public async Task<ODataResponseListReport> getReports(string ws)
PowerBIClient pbiClient = getPBIClient();

var reports = await pbiClient.Reports.GetReportsInGroupAsync(ws);
return reports;

public async Task<ReportEmbeddingData> getReportEmbeddingData(string ws, string rep)
PowerBIClient pbiClient = getPBIClient();

var report = await pbiClient.Reports.GetReportInGroupAsync(ws, rep);
var embedUrl = report.EmbedUrl;
var reportName = report.Name;
GenerateTokenRequest genTokenReqParam = new GenerateTokenRequest(accessLevel: "view");
string embedToken = (await pbiClient.Reports.GenerateTokenInGroupAsync(ws, rep, genTokenReqParam)).Token;
return new ReportEmbeddingData
type = "report",
reportId = rep,
reportName = reportName,
embedUrl = embedUrl,
accessToken = embedToken

Regular Visitor

Hi @Anonymous 


I have a similar issue in my production environment. Everything seems to be working correctly on my localhost, but when I moved to prod I don't receive the embed token. 


Did you solve this? How did you do it? 


Thank you in advance. 

Helpful resources

July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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