Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
The code snippet below works fine for a Generic Report which means with Internal Dataset, however If I try to GenerateToken for a Report with an External Dataset meaning a Dataset that lives in another Workspace it throws a 403 Forbidden.
Note: I'm using SPN to authenticate my request and SPN is an Admin of Both Workspace (Workspace where the External Dataset Lives and Workspace where the Report lives)
using (var pbiClient = await this.GetClientAsync().ConfigureAwait(false))
{
if (pbiClient != null)
{
var dataset = await pbiClient.Datasets.GetDatasetByIdInGroupAsync(groupId, datasetId).ConfigureAwait(false);
GenerateTokenRequest genereateTokenRequestParameters;
var identity = new EffectiveIdentity(user.Username.Trim(), new List<string> { dataset.Id })
{
Roles = new List<string> { securityRole }
};
genereateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view", identity: identity);
// THIS LINE OF CODE RETURNS 403 FOR REPORT WITH EXTERNAL DATASET,
// WHILE WORKS IF REPORT AND DATASET IS IN THE SAME WORKSPACE
var tokenResponse = await pbiClient.Reports.GenerateTokenInGroupAsync(reportGroupId, report.Id, genereateTokenRequestParameters).ConfigureAwait(false);
embedReport.EmbedToken = tokenResponse ?? throw new NullReferenceException($"Power BI token not generated. Report ID: {report.Id}");
embedReport.EmbedUrl = report.EmbedUrl;
embedReport.ReportId = report.Id;
return embedReport;
}
}
User | Count |
---|---|
8 | |
7 | |
2 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
4 |