Forum Discussion
ronnoc
9 years agoAdvocate II
power bi java script API - Finally have access tokens but no staticReportUrl
I have spent a good amount of time trying to properly embed a report using the javascript API, as far as I know the js API is the only way to get interactivity within embedded reports which is necess...
- 9 years ago
I embed my own reports with a sample code as below. Replace the id, token and embed url with yourself's, save it as a html file and open it in Chrome/IE/FF.
<html> <script src="../jquery.js"></script> <script src="../powerbi.js"></script> <script type="text/javascript"> window.onload = function () { var embedConfiguration = { type: 'report', accessToken: 'yourtokenhere', id: '51309815-f35b-xxxx-acb8-bc7245cd8f0c', //for Power BI Embedded //embedUrl: 'https://embedded.powerbi.com/appTokenReportEmbed?reportId=734503cf-1309-4892-xxxx-791d62c15x44' //for Power BI REST API embedUrl: 'https://msit.powerbi.com/reportEmbed?reportId=51309815-f35b-xxxx-acb8-bc7245cd8f0c' }; var $reportContainer = $('#reportContainer'); var report = powerbi.embed($reportContainer.get(0), embedConfiguration); report.fullscreen(); } </script> <div id="reportContainer"></div> </html>
Eric_Zhang
9 years agoMicrosoft Employee
I embed my own reports with a sample code as below. Replace the id, token and embed url with yourself's, save it as a html file and open it in Chrome/IE/FF.
<html>
<script src="../jquery.js"></script>
<script src="../powerbi.js"></script>
<script type="text/javascript">
window.onload = function () {
var embedConfiguration = {
type: 'report',
accessToken: 'yourtokenhere',
id: '51309815-f35b-xxxx-acb8-bc7245cd8f0c',
//for Power BI Embedded
//embedUrl: 'https://embedded.powerbi.com/appTokenReportEmbed?reportId=734503cf-1309-4892-xxxx-791d62c15x44'
//for Power BI REST API
embedUrl: 'https://msit.powerbi.com/reportEmbed?reportId=51309815-f35b-xxxx-acb8-bc7245cd8f0c'
};
var $reportContainer = $('#reportContainer');
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);
report.fullscreen();
}
</script>
<div id="reportContainer"></div>
</html>
Saraswathi
8 years agoFrequent Visitor
I have replaced the below given code with my report id, url and access token, saved as html file and opened in IE but its not working.
Can someone please help me to ressolve this issue.
Thanks
Saraswathi M