Forum Discussion
power bi java script API - Finally have access tokens but no staticReportUrl
- 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>
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>
- Cubist9 years agoAdvocate II
Eric_Zhang This solution doesn't work and must be updated or removed.
Reasons it doesn't work:
1) The script include paths you've referenced have changed and are invalid
2) You're hotlinking to GitHub files which does not work and against their terms of service
https://github.com/blog/1482-heads-up-nosniff-header-support-coming-to-chrome-and-firefox
- Saraswathi8 years agoFrequent Visitor
I have replaced the above sample code with my report id , access token and url , saved it as html file and opened in IE but the embedded report is not displaying.
Can someone please help me to ressolve this issue.
Thanks
Saraswathi M
- Saraswathi8 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