Hello i am trying to integrate my power bi reports to my angular and .net applications and i am getting "This content isn't available." Error. i follow multiple tutorials but anyone helps me to solve it
Backend controller (To get the tokens)
public class ReportController : BaseApiController { private static readonly string Username = ConfigurationManager.AppSettings["pbiUsername"]; private static readonly string Password = ConfigurationManager.AppSettings["pbiPassword"]; private static readonly string AuthorityUrl = ConfigurationManager.AppSettings["authorityUrl"]; private static readonly string ResourceUrl = ConfigurationManager.AppSettings["resourceUrl"]; private static readonly string ClientId = ConfigurationManager.AppSettings["clientId"]; private static readonly string ApiUrl = ConfigurationManager.AppSettings["apiUrl"]; private static readonly string GroupId = ConfigurationManager.AppSettings["groupId"]; [HttpGet] [Route("get")] public async Task<HttpResponseMessage> EmbedReport(string reportName) { var error = GetWebConfigErrors(); if (error != null) { return CreateApiResponse(HttpStatusCode.BadRequest, reportName); } // 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) { return CreateApiResponse(HttpStatusCode.BadRequest, reportName); } 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 reports. var reports = await client.Reports.GetReportsInGroupAsync(GroupId); // Get the first report in the group. var report = reports.Value.FirstOrDefault(); if (report == null) { return CreateApiResponse(HttpStatusCode.BadRequest, report); } // Generate Embed Token. var generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view"); var tokenResponse = client.Reports.GenerateTokenInGroup(GroupId, report.Id, generateTokenRequestParameters); Report myReport = client.Reports.GetReportInGroup(GroupId, report.Id); if (tokenResponse == null) { return CreateApiResponse(HttpStatusCode.BadRequest, report); } // Generate Embed Configuration. var embedConfig = new ReportConfigViewModel() { EmbedToken = tokenResponse, EmbedUrl = report.EmbedUrl, Id = report.Id }; return CreateApiResponse(HttpStatusCode.OK, embedConfig); } }
Angular Js Controller
$scope.service.get("Hola").then( function onSuccess(response) { $scope.embedUrl = response.data.embedUrl; $scope.accessToken = response.data.embedToken.token; debugger; }, function onError(response) { debugger; } )
html
<powerbi-report embed-url="embedUrl" access-token="accessToken"></powerbi-report>
if anyone can help me i will be greatfull