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
• 9,880 points
49 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
• 11,230 points

Related Questions In Power BI

0 votes
3 answers

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

Use ADAL.js that will give you an ...READ MORE

answered Jun 22, 2019 in Power BI by anonymous
4,626 views
0 votes
0 answers
0 votes
1 answer

how can I connect my web api with Power BI Reports?

Go to Home > Edit Queries > ...READ MORE

answered Oct 18, 2018 in Power BI by Annie97
• 2,160 points
9,679 views
0 votes
1 answer

I have a web API with basic authorisation and username and password. How do i connect to it in Power BI?

Hey, @There, I found your query is quite ...READ MORE

answered Oct 29, 2020 in Power BI by Gitika
• 65,770 points
3,718 views
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
678 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,361 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
700 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,281 views
0 votes
1 answer
0 votes
1 answer
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