<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Power BI embedded report iframe throws javascript error in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-report-iframe-throws-javascript-error/m-p/77028#M2659</link>
    <description>&lt;P&gt;We're developing a solution that requires us to put an embedded report on our pages using Power BI REST API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem that we have at the moment is that there's something wrong with the iframe JS code but we have no idea if it's something caused by us or simply a bug.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In order to embed the report we followed this article:&amp;nbsp;&lt;A href="https://azure.microsoft.com/en-us/documentation/articles/power-bi-embedded-iframe/" target="_blank"&gt;https://azure.microsoft.com/en-us/documentation/articles/power-bi-embedded-iframe/&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once we the page loads we receive the following error coming from the Power BI iframe (which is stuck on a fading logo animation):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;EM&gt;Invalid message data:jsCommon is not defined&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Inspecting the code inside the iframe we found the line that is causing the issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// Handle message from parent window
function receiveMessage(event) {
    if (event.data) {
        try {
            // This is the line that causes the exception.
            var messageData = jsCommon.JsonExtensions.isJsonString(event.data) ? JSON.parse(event.data) : event.data;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This instead is how we prepare the iframe:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;iframe id="reportIframe" src="{{ $powerBIReports['value'][0]['embedUrl'] }}"&amp;gt;&amp;lt;/iframe&amp;gt;
&amp;lt;script&amp;gt;

    $(document).ready(function()
    {
        var iframeReportElement = document.getElementById('reportIframe').contentWindow;
        var msg = {
            action: "loadReport",
            accessToken: "{{ $JWT }}",
            height: 500,
            width: 722
        };
        var msgTxt = JSON.stringify(msg);
        iframeReportElement.postMessage(msgTxt, '*');

        window.addEventListener('message', function (event)
        {
            console.error('PowerBI embedded error: ' + JSON.parse(event.data).error);
        });
     });

&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Oct 2016 07:36:10 GMT</pubDate>
    <dc:creator>Siannone</dc:creator>
    <dc:date>2016-10-11T07:36:10Z</dc:date>
    <item>
      <title>Power BI embedded report iframe throws javascript error</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-report-iframe-throws-javascript-error/m-p/77028#M2659</link>
      <description>&lt;P&gt;We're developing a solution that requires us to put an embedded report on our pages using Power BI REST API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem that we have at the moment is that there's something wrong with the iframe JS code but we have no idea if it's something caused by us or simply a bug.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In order to embed the report we followed this article:&amp;nbsp;&lt;A href="https://azure.microsoft.com/en-us/documentation/articles/power-bi-embedded-iframe/" target="_blank"&gt;https://azure.microsoft.com/en-us/documentation/articles/power-bi-embedded-iframe/&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once we the page loads we receive the following error coming from the Power BI iframe (which is stuck on a fading logo animation):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;EM&gt;Invalid message data:jsCommon is not defined&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Inspecting the code inside the iframe we found the line that is causing the issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// Handle message from parent window
function receiveMessage(event) {
    if (event.data) {
        try {
            // This is the line that causes the exception.
            var messageData = jsCommon.JsonExtensions.isJsonString(event.data) ? JSON.parse(event.data) : event.data;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This instead is how we prepare the iframe:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;iframe id="reportIframe" src="{{ $powerBIReports['value'][0]['embedUrl'] }}"&amp;gt;&amp;lt;/iframe&amp;gt;
&amp;lt;script&amp;gt;

    $(document).ready(function()
    {
        var iframeReportElement = document.getElementById('reportIframe').contentWindow;
        var msg = {
            action: "loadReport",
            accessToken: "{{ $JWT }}",
            height: 500,
            width: 722
        };
        var msgTxt = JSON.stringify(msg);
        iframeReportElement.postMessage(msgTxt, '*');

        window.addEventListener('message', function (event)
        {
            console.error('PowerBI embedded error: ' + JSON.parse(event.data).error);
        });
     });

&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2016 07:36:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-report-iframe-throws-javascript-error/m-p/77028#M2659</guid>
      <dc:creator>Siannone</dc:creator>
      <dc:date>2016-10-11T07:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI embedded report iframe throws javascript error</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-report-iframe-throws-javascript-error/m-p/77216#M2668</link>
      <description>&lt;P&gt;PowerBI embedded API has changed recently so the tutorial is possibly out of date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;somewhat related: &lt;A href="https://stackoverflow.com/questions/38958046/powerbi-embedded-provision-token-generation-error" target="_self"&gt;SO question&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More specificaly, &lt;A href="https://github.com/Azure-Samples/power-bi-embedded-integrate-report-into-web-app/blob/master/EmbedSample/Controllers/DashboardController.cs" target="_self"&gt;more up-to-date tutorial&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2016 12:35:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-embedded-report-iframe-throws-javascript-error/m-p/77216#M2668</guid>
      <dc:creator>mpo</dc:creator>
      <dc:date>2016-10-11T12:35:51Z</dc:date>
    </item>
  </channel>
</rss>

