How can I embed a Power BI Report Server report into a web application using JavaScript API

0 votes
How can I embed a Power BI Report Server report into a web application using JavaScript API?

I need guidance on embedding a report hosted on Power BI Report Server into a web application using the Power BI JavaScript API. What steps or configurations are required to achieve this, and are there any prerequisites, such as authentication or specific API calls, that I need to handle?
Dec 13, 2024 in Power BI by Evanjalin
• 19,330 points
149 views

1 answer to this question.

0 votes

Use the following method to embed a report hosted on Power BI Report Server into a web application through the Power BI JavaScript API:

Prerequisites:

Power BI Report Server: The required report must be published onto the Power BI Report Server before embedding.

Web Application Hosting: A web server or environment for hosting your application.

Authentication: Use the appropriate authentication method, such as Kerberos or NTLM, because the Power BI Report Server uses Windows Authentication by default.

Power BI JavaScript API Library: To include the Power BI JavaScript API library in your web application.

Embedding Steps:

Construct a URL for a report.

Obtain the URL of your report hosted on the Power BI Report Server. The URL should include parameters such as rs: Embed=true in order to enable its embedding.

Example:

https://your-report-server/reports/powerbi/MyReport?rs:Embed=true

Embed the Report in an IFrame:

  • Use an HTML <iframe> to display the report in your application.
  • Include the authentication headers or configure server settings to handle credentials.

Example HTML:

<iframe id="reportContainer" width="100%" height="600px" src=""></iframe>

Use JavaScript API:

  • Include the Power BI JavaScript library in your project.
<script src="https://cdn.powerbi.com/libs/powerbi-client/2.19.0/powerbi.min.js"></script>

Initialize and Embed the Report:

  • Use JavaScript to initialize the Power BI client and load the report dynamically.

Example JavaScript:

const models = window['powerbi-client'].models; 

// Report configuration 

const embedConfig = { 

embedUrl: 'https://your-report-server/reports/powerbi/MyReport?rs:Embed=true', 

tokenType: models.TokenType.None, // For Power BI Report Servertype: 'report',

};

/ Get the HTML container element 

const reportContainer = document.getElementById('reportContainer');

// Embed the report 

const powerbi = new window['powerbi-client'].service.Service();

 powerbi.embed(reportContainer, embedConfig);

Authentication Mechanism:
Power BI Report Server uses local Windows accounts and does not use Azure AD as in Power BI Service. Ensure:

The users are endowed with proper Windows credentials to log into the report.
Configure proper cross-origin resource sharing (CORS) if it is being hosted on another server with a web application.

answered Dec 13, 2024 by pooja
• 16,840 points

Related Questions In Power BI

0 votes
1 answer

How can I embed Power BI reports into a Xamarin mobile application?

Embedding Power BI reports into a Xamarin ...READ MORE

answered Feb 28 in Power BI by anonymous
• 19,330 points
47 views
0 votes
3 answers

How do I get token using javascript API while trying to embed graphs using Power BI

You need to use the generate embed ...READ MORE

answered Oct 10, 2023 in Power BI by Monika kale

edited Mar 5 4,749 views
+1 vote
1 answer
0 votes
1 answer
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
740 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,439 views
0 votes
1 answer

How do Report server e-mail deliver reports?

Report server e-mail delivery can deliver reports ...READ MORE

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

Custom title and logo in Power BI Report Server

Your title can always be added to ...READ MORE

answered Feb 9, 2022 in Power BI by CoolCoder
• 4,420 points
1,378 views
0 votes
0 answers
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