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.
I have an app that displays power bi reports from a workspace.
When I use fabric as a datasource, I get an error in
var tokenResponse =
await client.Reports.GenerateTokenAsync(
new Guid(SelectedWorkspaceId),
new Guid(SelectedReportId),
generateTokenRequestParameters);
I can get an fabric access token using a service principle, but this doesn't work when passed to Show report
string[] scopes = new string[] { "https://api.fabric.microsoft.com/.default" };
ConfidentialClientApplicationBuilder confidentialClientAppBuilder =
ConfidentialClientApplicationBuilder.Create(ClientId)
.WithClientSecret(ClientSecret)
.WithAuthority(Authority)
.WithTenantId(tenantId);
IConfidentialClientApplication confidentialClientApplication = confidentialClientAppBuilder.Build();
AuthenticationResult result = await confidentialClientApplication.AcquireTokenForClient(scopes)
.ExecuteAsync()
.ConfigureAwait(false);
return result.AccessToken;
HI @Founder,
It seems like you faced the 400 error, this error occurs when a request sent to a website server is incorrect or corrupt, and the server receiving the request can’t understand it.
rest - 400 BAD request HTTP error code meaning? - Stack Overflow
AFAIK, the root URL of rest API should be https://api.powerbi.com/v1.0/myorg. According to your descriptions, it seems like you modify it to https://api.fabric.microsoft.com/ and it did not able to be responded with these requests.
Regards,
Xiaoxin Sheng
using (var client = new PowerBIClient(
new Uri("https://api.powerbi.com/"), tokenCredentials))
{
var report =
await client.Reports.GetReportInGroupAsync(
new Guid(SelectedWorkspaceId),
new Guid(SelectedReportId));
var generateTokenRequestParameters =
new GenerateTokenRequest(accessLevel: TokenAccessLevel.View);
var tokenResponse =
await client.Reports.GenerateTokenAsync(
new Guid(SelectedWorkspaceId),
new Guid(SelectedReportId),
generateTokenRequestParameters);
await Interop.ShowReport(
JSRuntime,
PowerBIElement,
tokenResponse.Token,
report.EmbedUrl,
report.Id.ToString());
}
This is the code I'm using to get the token. This is what is producing the error
HI @Founder,
So you mean these processes get the return the error messages that you faced and motion at the above? Have you tried to create a common function to invoke these operations instead of package into the using functions?
The GC may affect the await processings, perhaps you can add some output trace to confirm these required parameters has correctly generated in your codes processings.
BTW, are you worked with fabric API? AFAIK, current it seems not support service principal.
Regards,
Xiaoxin Sheng
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
3 | |
1 | |
1 | |
1 |
User | Count |
---|---|
26 | |
3 | |
2 | |
2 | |
2 |