Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hi everyone,
How to fix https://api.powerbi.com/powerbi/globalservice/v201606/clusterdetails (401).
I am embedded in my .net framework (webforms) application, a paginated report from power bi service, when I press a button I need the report to appear.
When I click the button, the report should open in a container, but I get the error I mentioned above. The strange thing is that the report can be seen using the Microsoft application 'Power BI Embedded Sample', but it is not shown in my application.
In the Microsoft application, however, it can be seen embedded
ASPX File:
(javascript)
<script type="text/javascript">
function embedReport() {
var models = window['powerbi-client'].models;;
let embedConfiguration = {
accessToken: '<%= LiteralAccessToken.Text %>',
embedUrl: '<%= LiteralEmbedUrl.Text %>',
id: '<%= LiteralReportId.Text %>',
tokenType: models.TokenType.Aad,
type: 'report'
};
let dashboardContainer = $('#reportContainer')[0];
let dashboard = powerbi.embed(dashboardContainer, embedConfiguration);
}
document.addEventListener('DOMContentLoaded', function () {
embedReport();
});
</script>
(body)
...........................
<asp:Literal ID="LiteralReportId" runat="server" Visible="false"></asp:Literal>
<asp:Literal ID="LiteralEmbedUrl" runat="server" Visible="false"></asp:Literal>
<asp:Literal ID="LiteralTokenType" runat="server" Visible="false"></asp:Literal>
<asp:Literal ID="LiteralAccessToken" runat="server" Visible="false"></asp:Literal>
<asp:Button ID="btnLoadReport" runat="server" OnClick="btnLoadReport_Click" Text="Cargar Reporte" />
<div id="reportContainer" style="height: 600px; width: 100%;"></div>
.............................
CS File:
.............................................................................
protected void btnLoadReport_Click(object sender, EventArgs e)
{
EmbedPowerBIReport().Wait();
}
private async Task EmbedPowerBIReport()
{
Guid groupId = new Guid("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
Guid reportId = new Guid("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy");
using (HttpClient httpClient = new HttpClient())
{
// Obtén el token de acceso
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("grant_type", "client_credentials"),
new KeyValuePair<string, string>("client_id", clientId),
new KeyValuePair<string, string>("client_secret", clientSecret),
new KeyValuePair<string, string>("scope", "https://analysis.windows.net/powerbi/api/.default")
});
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
var tokenResponse = await httpClient.PostAsync("https://login.microsoftonline.com/zzzzzzzzzzzzzzzzzzzzzzzzzzzzz/oauth2/v2.0/token", content);
var tokenContent = await tokenResponse.Content.ReadAsStringAsync();
var token = Newtonsoft.Json.JsonConvert.DeserializeObject<TokenResponse>(tokenContent);
TokenCredentials tokenCredentials = new TokenCredentials(token.access_token, "Bearer");
using (var client = new PowerBIClient(new Uri(apiUrl), tokenCredentials))
{
var report = await client.Reports.GetReportInGroupAsync(groupId, reportId);
LiteralReportId.Text = reportId.ToString();
LiteralEmbedUrl.Text = report.EmbedUrl;
LiteralTokenType.Text = token.token_type;
LiteralAccessToken.Text = token.access_token;
}
}
ScriptManager.RegisterStartupScript(this, GetType(), "embedReport", "embedReport();", true);
}
...............................................................................
Help me please!
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 20 | |
| 11 | |
| 10 | |
| 9 | |
| 9 |
| User | Count |
|---|---|
| 53 | |
| 38 | |
| 36 | |
| 25 | |
| 25 |