Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
bright
Helper I
Helper I

dashboard embed html iframe not working

I have project embede  power bi dashboard but i embed after he doesn't working

when i check the console he show the error massage 

 

VM894 powerbiportal.dependencies.bundle.min.js:130 ReferenceError: powerBIAccessToken is not defined
    at r.setAuthorizationHeader (VM897 powerbiportal.common.bundle.min.js:40)
    at r.powerbiRequestOptions (VM897 powerbiportal.common.bundle.min.js:40)
    at i.Object.defineProperty.get [as requestOptions] (VM897 powerbiportal.common.bundle.min.js:37)
    at i.n.sendLongPollRequest (VM897 powerbiportal.common.bundle.min.js:37)
    at VM897 powerbiportal.common.bundle.min.js:37
    at VM894 powerbiportal.dependencies.bundle.min.js:170
    at e (VM894 powerbiportal.dependencies.bundle.min.js:59)
    at VM894 powerbiportal.dependencies.bundle.min.js:62

My powerbi embed dashboard code 

 

著是demo
<?php
include('powerbi.php');//匯入我自訂的powerbi libery
$powerbi =  new powerbi();
$report = $powerbi->report();
$report  = json_decode($report);
$reportvalue = $report->value;
$access = $powerbi->token();
$token_type = $access->token_type;
$token = $access->access_token;
$dashbord = $powerbi->dashbord();
$dashbord = json_decode($dashbord);
$dashbord_value = $dashbord->value;
//$workspace =  $powerbi->workspace();
?>
<input type="button" value="報告  &#10; report" onclick="report()">
<input type="button" value="儀錶  &#10; dashbord" onclick="dashbord()">

            <iframe ID="iFrameEmbedReport" height="500px" width="900px"></iframe>
			<input type='hidden' value="<?=$token?>" id="MainContent_accessToken">
			<input type="hidden" value="<?=$reportvalue[0]->embedUrl?>" id="MainContent_ReportEmbedUrl">
			<input type="hidden" value="<?=$dashbord_value[0]->embedUrl?>" id="DashbordUrl">
			

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript">
        //This code is for sample purposes only.

        //Configure IFrame for the Report after you have an Access Token. See Default.aspx.cs to learn how to get an Access Token
		function report(){
			
            if ("" != document.getElementById('MainContent_accessToken').value)
            {
                var iframe = document.getElementById('iFrameEmbedReport');

                // To load a Report do the following:
                // Set the IFrame source to the EmbedUrl from the Get Reports operation
                iframe.src=document.getElementById('MainContent_ReportEmbedUrl').value;

                // Add an onload handler to submit the access token
                iframe.onload = postActionLoadReport;
            }
       
		}
        function dashbord(){
			if ("" != document.getElementById('MainContent_accessToken').value)
            {
                var iframe = document.getElementById('iFrameEmbedReport');
				iframe.src=document.getElementById('DashbordUrl').value + "&width=800&height=500";
				iframe.onload = postdashborad;

              
                

                // Add an onload handler to submit the access token
               
            }
		} 
        // Post the access token to the IFrame
        function postActionLoadReport() {

            // Construct the push message structure
            // this structure also supports setting the reportId, groupId, height, and width.
            // when using a report in a group, you must provide the groupId on the iFrame SRC
            var m = {
                action: "loadReport",
                accessToken: document.getElementById('MainContent_accessToken').value
            };
            message = JSON.stringify(m);

            // push the message.
            iframe = document.getElementById('iFrameEmbedReport');
            iframe.contentWindow.postMessage(message, "*");;
        }
        function postdashborad(){
			
			
			var m = {   action: "loadTile" , accessToken: "<?=$token?>", height: 500 , width: 722 };
			message = JSON.stringify(m);  
			iframe = document.getElementById('iFrameEmbedReport'); iframe.contentWindow.postMessage(message, "*");
			
		}
		

    </script>

I search many place everywhere said powerbi dashborad not support is really ? Is it cause my code the working result ? 

 

how to fix this porblem ? 

Only my report can working is very strange why it always say not find accesstoken but i have give him 

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@bright,

 

Currently, I do not find an available way to embed a dashboard. The Power BI REST API for dashboard operations is still a preview version. You may submit an idea or leave a comment at GitHub.

Community Support Team _ Sam Zha
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

3 REPLIES 3
bright
Helper I
Helper I

I wrote my i idea who can vot this idea

v-chuncz-msft
Community Support
Community Support

@bright,

 

Currently, I do not find an available way to embed a dashboard. The Power BI REST API for dashboard operations is still a preview version. You may submit an idea or leave a comment at GitHub.

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

@v-chuncz-msft: Can we upload .pbix files using Power BI Rest API?

Do we have any way to provide access to uploaded reports?

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Kudoed Authors