cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Report and Dashboard not render on my webpage

Hi,

 

 

I want to embed the PowerBi Reports & Dashboards in my web application by using PHP Curl and JavaScript Api. For that, I already create azure account and also registered the application in PowerBi. I get all the list of reports and dashboards which are already creted in my powerbi desktop but when I call for a report by using embed url I got the response as:

 

"This content isn't available"
Learn more about Power BI.

 

You can check this here : http://quizgeny.com/arquam/testing.php

 

My code for calling the reports after getting embedded token is :

<?php
$curlGetUrl = curl_init();
curl_setopt_array($curlGetUrl, array(

CURLOPT_URL => "https://api.powerbi.com/v1.0/myorg/reports",

CURLOPT_RETURNTRANSFER => true,

CURLOPT_ENCODING => "",

CURLOPT_MAXREDIRS => 10,

CURLOPT_TIMEOUT => 30,

CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

CURLOPT_CUSTOMREQUEST => "GET",

CURLOPT_HTTPHEADER => array(

"Authorization: $embeddedToken",

"Cache-Control: no-cache",

),

));

$embedResponse = curl_exec($curlGetUrl);

$embedError = curl_error($curlGetUrl);

curl_close($$curlGetUrl);


if ($embedError) {

echo "cURL Error #:" . $embedError;

} else {

$embedResponse = json_decode($embedResponse, true);

$embedUrl = $embedResponse['value'][0]['embedUrl'];

$reportId = $embedResponse['value'][0]['id'];

}
?>

<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript" language="javascript" src="https://rawgit.com/Microsoft/PowerBI-JavaScript/master/dist/powerbi.min.js"></script>
<script src="https://rawgit.com/Microsoft/PowerBI-JavaScript/master/dist/powerbi.js"></script>

<h1>Power BI Embedded Demo</h1>
<div id="reportContainer" style="width: 80%; height: 800px;"></div>
<script>

var accessToken = "<?php echo $token?>";


var embedUrl = "<?php echo $embeddedUrl?>";


var embedReportId = "<?php echo $reportId?>";


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


var config = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: accessToken,
embedUrl: embedUrl,
reportId: embedReportId,
permissions: models.Permissions.All,

};

var reportContainer = document.getElementById('reportContainer');
var report = powerbi.embed(reportContainer, config);
</script>

 

 


Please give me the solution for this issue.

 

 

Thank You

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
Microsoft
Microsoft

Hi @syedahmad,

 

I'm almost sure the cause is the expiration of the token. As far as I know, the token will expire in one hour. You can replace the token with a new token for a test. You also need to find a way to refresh the token automatically. 

I also found something else in the source code. The token is an AAD token rather than an Embed token. Please refer to power-bi/embedtoken and https://www.youtube.com/watch?v=GPHHdDRSlis for how to get the embed token. 

 

tokenType: models.TokenType.Embed,

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

11 REPLIES 11

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.