Embedding Power Bi Report Promise is not defined powerbi.js

0 votes

So, I've created a report on Power BI. I want to embed this report to my MVC site. Here is the code:-

private static readonly string ClientID = ConfigurationManager.AppSettings["ClientID"];
private static readonly string ClientSecret = ConfigurationManager.AppSettings["ClientSecret"];
private static readonly string RedirectUrl = ConfigurationManager.AppSettings["RedirectUrl"];
private static readonly string AADAuthorityUri = ConfigurationManager.AppSettings["AADAuthorityUri"];
private static readonly string PowerBiAPI = ConfigurationManager.AppSettings["PowerBiAPI"];
private static readonly string PowerBiDataset = ConfigurationManager.AppSettings["PowerBiDataset"];
 private static readonly string baseUri = PowerBiDataset;
 private static string accessToken = string.Empty;

 public string GetAccessToken(string authorizationCode, string clientID, string clientSecret, string redirectUri)
        {      
            TokenCache TC = new TokenCache();
            string authority = AADAuthorityUri;
            AuthenticationContext AC = new AuthenticationContext(authority, TC);
            ClientCredential cc = new ClientCredential(clientID, clientSecret);
            return AC.AcquireTokenByAuthorizationCodeAsync(
                authorizationCode,
                new Uri(redirectUri), cc).Result.AccessToken;
        }

        public void GetAuthorizationCode()
        {
            var @params = new NameValueCollection
            {
                {"response_type", "code"},
                {"client_id", ClientID},
                {"resource", PowerBiAPI},
                { "redirect_uri", RedirectUrl}
            };

            var queryString = HttpUtility.ParseQueryString(string.Empty);
            queryString.Add(@params);
            Response.Redirect(String.Format(AADAuthorityUri + "?{0}", queryString));
        }

        public ActionResult Index()
        {
            if (Request.QueryString["code"] != null)
            {
                Session["AccessToken"] = GetAccessToken(
                    HttpContext.Request["code"],
                    ClientID,
                    ClientSecret,
                    RedirectUrl);
            }
            if (Session["AccessToken"] != null)
            {
                accessToken = Session["AccessToken"].ToString();
                System.Net.WebRequest request = System.Net.WebRequest.Create(
                 String.Format("{0}/Reports",
                 baseUri)) as System.Net.HttpWebRequest;

                request.Method = "GET";
                request.ContentLength = 0;
                request.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken));
                using (var response = request.GetResponse() as System.Net.HttpWebResponse)
                {
                    using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
                    {
                        PBIReports Reports = JsonConvert.DeserializeObject<PBIReports>(reader.ReadToEnd());
                        if (Reports.value.Length > 0)
                        {
                            PBIReport report = Reports.value[13];
                            return View(report);
                        }
                    }
                }
            }
            GetAuthorizationCode();
            return View();
        }

On Redirecting to "this", it goes for power bi login page and after I sign in it redirects back to this page (as homepage and redirect URL are same). After getting all the report data, after some time an error message comes up saying Unhandled exception at line 5153, column 11 in http://localhost:34244/Scripts/powerbi.js 0x800a1391 - JavaScript runtime error: 'Promise' is undefined

Oct 30, 2018 in Power BI by Upasana
• 8,470 points

edited Oct 30, 2018 by Upasana 234 views

1 answer to this question.

0 votes

IE does not yet support Promise. You can enable support by including an external library. Please see Microsoft's comments on this in relation to Power BI here - Support for IE8 and Promises?

answered Oct 30, 2018 by Shubham
• 13,210 points

Related Questions In Power BI

0 votes
1 answer

what is power BI report server

Power BI Report Server is an on-premises ...READ MORE

answered Oct 15, 2018 in Power BI by Hannah
• 14,080 points
32 views
0 votes
1 answer
0 votes
1 answer

Refresh power bi report every hour

You’ll have a Power BI service option ...READ MORE

answered Sep 24, 2018 in Power BI by Hannah
• 14,080 points
213 views
0 votes
1 answer

Is it possible to manage limits while using dedicated capacity power bi embedded app service?

These limits are not related to using ...READ MORE

answered Sep 24, 2018 in Power BI by Hannah
• 14,080 points
43 views
0 votes
1 answer

Unable to install connector for Power Bi and PostgreSQL

I think the problem is not at ...READ MORE

answered Aug 21, 2018 in Power BI by nirvana
• 3,060 points
481 views
0 votes
1 answer

Authenticate on an ASP.Net Forms Authorization website from a console app

Essentially, we need to record a regular ...READ MORE

answered Sep 20, 2018 in IoT (Internet of Things) by Annie97
• 2,190 points
30 views
0 votes
1 answer

connecting to Power BI API using non-interactive authentication?

Try changing the resource URI: var result = ...READ MORE

answered Oct 30, 2018 in Power BI by Shubham
• 13,210 points
554 views
0 votes
1 answer

Validate Amazon SessionToken / Cognito?

You can use it as an OAuth token ...READ MORE

answered Nov 14, 2018 in AWS by Theodor
• 740 points
110 views
0 votes
1 answer

Power BI Service : System.Object type is not supported

You have to modify the stream analytics ...READ MORE

answered Feb 6 in Power BI by Shubham
• 13,210 points
22 views
0 votes
1 answer

Embedding a dashboard using Java in Power BI

Make sure to use the correct embedURL, ...READ MORE

answered Nov 30, 2018 in Power BI by Shubham
• 13,210 points
664 views