<?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 Error creating new reports using Power BI Embedded in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Error-creating-new-reports-using-Power-BI-Embedded/m-p/328210#M9689</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've written the following code to try create a new report using Power BI Embedded:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;authContext.acquireToken(window.config.endpoints.powerbiUri, function (error, token) {

                let datasetId = $("#datasetId").val();
                let embedContainer = $("#embedContainer").get(0);
           
                let models = window['powerbi-client'].models;

                let config = {
                    accessToken: token,
                    datasetId: datasetId,
                    embedUrl: "https://embedded.powerbi.com/appTokenReportEmbed"
                };

                let report = powerbi.createReport(embedContainer, config);

                report.on("saved", function (event) {
                    let msg = `report saved ${JSON.stringify(event.detail, null, "  ")} `;
                    alert(msg);
                });

                report.on("error", function (event) {
                    let msg = `error creating report saved ${JSON.stringify(event.detail, null, "  ")} `;
                    console.log(msg);
                });

            });&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Everytime the code runs, an NotAuthorized error is logged however. The account that I used to test my code has admin permissions on Power BI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;error creating report saved {
  "message": "CreateReportFailed",
  "detailedMessage": null,
  "technicalDetails": {
    "requestId": "4a909e2f-4552-0433-13ed-3e9a3d2346b2"
  },
  "errorCode": "NotAuthorized"
} &lt;/PRE&gt;&lt;P&gt;What is wrong with my security ? I'm using the "User owns data" scenario btw...&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Gunther&lt;/P&gt;</description>
    <pubDate>Fri, 22 Dec 2017 13:29:02 GMT</pubDate>
    <dc:creator>GunterM</dc:creator>
    <dc:date>2017-12-22T13:29:02Z</dc:date>
    <item>
      <title>Error creating new reports using Power BI Embedded</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Error-creating-new-reports-using-Power-BI-Embedded/m-p/328210#M9689</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've written the following code to try create a new report using Power BI Embedded:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;authContext.acquireToken(window.config.endpoints.powerbiUri, function (error, token) {

                let datasetId = $("#datasetId").val();
                let embedContainer = $("#embedContainer").get(0);
           
                let models = window['powerbi-client'].models;

                let config = {
                    accessToken: token,
                    datasetId: datasetId,
                    embedUrl: "https://embedded.powerbi.com/appTokenReportEmbed"
                };

                let report = powerbi.createReport(embedContainer, config);

                report.on("saved", function (event) {
                    let msg = `report saved ${JSON.stringify(event.detail, null, "  ")} `;
                    alert(msg);
                });

                report.on("error", function (event) {
                    let msg = `error creating report saved ${JSON.stringify(event.detail, null, "  ")} `;
                    console.log(msg);
                });

            });&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Everytime the code runs, an NotAuthorized error is logged however. The account that I used to test my code has admin permissions on Power BI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;error creating report saved {
  "message": "CreateReportFailed",
  "detailedMessage": null,
  "technicalDetails": {
    "requestId": "4a909e2f-4552-0433-13ed-3e9a3d2346b2"
  },
  "errorCode": "NotAuthorized"
} &lt;/PRE&gt;&lt;P&gt;What is wrong with my security ? I'm using the "User owns data" scenario btw...&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Gunther&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2017 13:29:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Error-creating-new-reports-using-Power-BI-Embedded/m-p/328210#M9689</guid>
      <dc:creator>GunterM</dc:creator>
      <dc:date>2017-12-22T13:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Error creating new reports using Power BI Embedded</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Error-creating-new-reports-using-Power-BI-Embedded/m-p/328973#M9729</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/49763"&gt;@GunterM&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems to be that the embedded token is invalid. How did you get the token?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, &lt;A href="https://community.powerbi.com/t5/Developer/Validate-Power-BI-Embed-Token/td-p/170391" target="_self"&gt;here&lt;/A&gt; is similar thread which should help you make sure the token is valid.&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.fabric.microsoft.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2017 07:35:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Error-creating-new-reports-using-Power-BI-Embedded/m-p/328973#M9729</guid>
      <dc:creator>v-ljerr-msft</dc:creator>
      <dc:date>2017-12-26T07:35:20Z</dc:date>
    </item>
  </channel>
</rss>

