Hi I have been working with power bi embedded to embed reports and dashboards in an app owns data application and this has overall been working well. However we have recently started building das...
daveParso
9 years agoFrequent Visitor
Hi
I have been working with power bi embedded to embed reports and dashboards in an app owns data and this has overall been working well. However we have recently started building dashboards made up of tiles as opposed to pinning an entire report to the dashboard and now when trying to display this kind of dashboard we are running into issues. The images below depict exactly what is happening and the error that seems to be being thrown:
Any help with this would be greatly appreciated.
- daveParso9 years agoFrequent Visitor
Also figured it would be worthwhile submitting my embedDashboard function
public async Task<ActionResult> EmbedDashboard() { EmbedConfig[] errorArr = new EmbedConfig[1]; //loop that finds the groupID assigned to the currently logged in user foreach (Claim claim in ClaimsPrincipal.Current.Claims) { if (claim.Type == "extension_GroupID") { GroupId = claim.Value; } } var error = GetWebConfigErrors(); if (error != null) { errorArr[0] = new EmbedConfig() { ErrorMessage = error }; return View(errorArr); } // Create a user password cradentials. var credential = new UserPasswordCredential(Username, Password); // Authenticate using created credentials var authenticationContext = new AuthenticationContext(AuthorityUrl); var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ClientId, credential); if (authenticationResult == null) { errorArr[0] = new EmbedConfig() { ErrorMessage = "Authentication failed." }; return View(errorArr); } var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer"); // Create a Power BI Client object. It will be used to call Power BI APIs. using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials)) { // Get a list of dashboards. var dashboards = await client.Dashboards.GetDashboardsInGroupAsync(GroupId); if (dashboards.Value.Count == 0) { errorArr[0] = new EmbedConfig() { ErrorMessage = "Group has no dashboards." }; return View(errorArr); } EmbedConfig[] configArr = new EmbedConfig[dashboards.Value.Count]; for (int i = 0; i < dashboards.Value.Count; i++) { // Get the i'th element in the group var dashboard = dashboards.Value.ElementAtOrDefault(i); // Generate Embed Token. var generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view"); var tokenResponse = await client.Dashboards.GenerateTokenInGroupAsync(GroupId, dashboard.Id, generateTokenRequestParameters); if (tokenResponse == null) { errorArr[i] = new EmbedConfig() { ErrorMessage = "Failed to generate embed token." }; return View(errorArr); } //populate an array with information about every dashboard in the workspace configArr[i] = new EmbedConfig() { EmbedToken = tokenResponse, EmbedUrl = dashboard.EmbedUrl, Id = dashboard.Id, Dashboards = dashboards }; } return View(configArr); } }