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,620 points

edited Oct 30, 2018 by Upasana 2,074 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,490 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
• 18,520 points
658 views
0 votes
1 answer

How is Power BI Report Server different from SQL Server Reporting Services and the Power BI online service

Power BI report server is deployed on-premises ...READ MORE

answered Oct 15, 2018 in Power BI by Hannah
• 18,520 points
1,309 views
0 votes
1 answer

Method not found: Void Microsoft.PowerBI.Api.V2.PowerBIClient..ctor - Power BI Embedded

There appears to be a version difference ...READ MORE

answered Mar 14, 2022 in Power BI by gaurav
• 23,260 points
1,443 views
0 votes
0 answers

The page cannot be displayed because an internal server error has occurred on server

When  I've deployed the website I installed  ...READ MORE

May 23, 2022 in Others by Kichu
• 19,040 points
1,137 views
0 votes
1 answer

Examples of dynamic polymorphism in c#

Check the example of polymorphism below. We ...READ MORE

answered Jun 7, 2022 in C# by pranav
• 2,590 points
876 views
0 votes
1 answer

Reading a key from the Web.Config using ConfigurationManager

Instead of any other thing, use the ...READ MORE

answered Jun 11, 2022 in C# by pranav
• 2,590 points
5,097 views
0 votes
1 answer

Logging DML operations in ASP.NET MVC project

There are several options. You might register an ...READ MORE

answered Jun 14, 2022 in C# by jyoti
• 1,240 points
1,210 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 7, 2019 in Power BI by Shubham
• 13,490 points
768 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,490 points
5,047 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP