<?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 binding a dataset dynamically to a PowerBI embedded report in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Error-binding-a-dataset-dynamically-to-a-PowerBI-embedded-report/m-p/3975409#M53155</link>
    <description>&lt;P&gt;I have a PowerBI embedded report in my web application. The data for each of my customers is stored in their own dataset (semantic model). Instead of creating a pair of report-dataset for each customer, I would like to have one single report and to dynamically select to with dataset connect in order to load the data.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;According to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/bind-report-datasets" target="_blank" rel="nofollow noopener noreferrer"&gt;this article&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;it is possible to connect a report to multiple datasets dynamically.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;So, I published my "report" and its "dataset" to a premium Workspace in powerbi-online. I tested the embedding and it works perfectly. Then I made a copy of the report and published to the same Workspace, so now I have "report", "dataset", "report (test2)", "dataset (test2)". Note that "dataset" and "dataset (test2)" are identical except for their name. And since all components ("report", "dataset" and "dataset (test2)") are in the same Workspace, they all share the same permissions (right?).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So, following the example in the article I implemented the javascript like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;var&lt;/SPAN&gt; reportLoadConfig = {
       &lt;SPAN class=""&gt;type&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"report"&lt;/SPAN&gt;,        
       &lt;SPAN class=""&gt;tokenType&lt;/SPAN&gt;: models.&lt;SPAN class=""&gt;TokenType&lt;/SPAN&gt;.&lt;SPAN class=""&gt;Embed&lt;/SPAN&gt;,
       &lt;SPAN class=""&gt;filters&lt;/SPAN&gt;: [filter_user],
       &lt;SPAN class=""&gt;datasetBinding&lt;/SPAN&gt;: {
           &lt;SPAN class=""&gt;sourceDatasetId&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"67e095eb-0570-444f-a2c5-0c7b68f9ff85"&lt;/SPAN&gt;, # dataset
           &lt;SPAN class=""&gt;targetDatasetId&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"7a274ca6-7ed0-4bd1-a832-f9732f96164a"&lt;/SPAN&gt;  # dataset (test2)
       }
   };
 
   $.&lt;SPAN class=""&gt;ajax&lt;/SPAN&gt;({
       &lt;SPAN class=""&gt;type&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"GET"&lt;/SPAN&gt;,
       &lt;SPAN class=""&gt;url&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"/getembedinfo_filtered?report=06212621-c8cc-4153-a001-09c98ff2ceb4"&lt;/SPAN&gt;,
       &lt;SPAN class=""&gt;dataType&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"json"&lt;/SPAN&gt;,
       &lt;SPAN class=""&gt;success&lt;/SPAN&gt;: &lt;SPAN class=""&gt;function&lt;/SPAN&gt; (&lt;SPAN class=""&gt;data&lt;/SPAN&gt;) {
           &lt;SPAN class=""&gt;var&lt;/SPAN&gt; embedData = $.&lt;SPAN class=""&gt;parseJSON&lt;/SPAN&gt;(data);
           reportLoadConfig.&lt;SPAN class=""&gt;accessToken&lt;/SPAN&gt; = embedData.&lt;SPAN class=""&gt;accessToken&lt;/SPAN&gt;;
           reportLoadConfig[&lt;SPAN class=""&gt;"settings"&lt;/SPAN&gt;] = {
               &lt;SPAN class=""&gt;filterPaneEnabled&lt;/SPAN&gt;: &lt;SPAN class=""&gt;false&lt;/SPAN&gt;,
               &lt;SPAN class=""&gt;navContentPaneEnabled&lt;/SPAN&gt;: &lt;SPAN class=""&gt;true&lt;/SPAN&gt;
           };
 
           &lt;SPAN class=""&gt;// Embed Power BI report when Access token and Embed URL are available&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;var&lt;/SPAN&gt; report = powerbi.&lt;SPAN class=""&gt;embed&lt;/SPAN&gt;(reportContainer, reportLoadConfig);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I get an error "This content isn't available."&lt;/P&gt;&lt;P&gt;Embedding Error: {message: 'LoadReportFailed', detailedMessage: 'Get report failed', errorCode: '403', level: 6, technicalDetails: {…}}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jun 2024 21:18:19 GMT</pubDate>
    <dc:creator>apoloduvalis</dc:creator>
    <dc:date>2024-06-05T21:18:19Z</dc:date>
    <item>
      <title>Error binding a dataset dynamically to a PowerBI embedded report</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Error-binding-a-dataset-dynamically-to-a-PowerBI-embedded-report/m-p/3975409#M53155</link>
      <description>&lt;P&gt;I have a PowerBI embedded report in my web application. The data for each of my customers is stored in their own dataset (semantic model). Instead of creating a pair of report-dataset for each customer, I would like to have one single report and to dynamically select to with dataset connect in order to load the data.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;According to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/bind-report-datasets" target="_blank" rel="nofollow noopener noreferrer"&gt;this article&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;it is possible to connect a report to multiple datasets dynamically.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;So, I published my "report" and its "dataset" to a premium Workspace in powerbi-online. I tested the embedding and it works perfectly. Then I made a copy of the report and published to the same Workspace, so now I have "report", "dataset", "report (test2)", "dataset (test2)". Note that "dataset" and "dataset (test2)" are identical except for their name. And since all components ("report", "dataset" and "dataset (test2)") are in the same Workspace, they all share the same permissions (right?).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So, following the example in the article I implemented the javascript like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;var&lt;/SPAN&gt; reportLoadConfig = {
       &lt;SPAN class=""&gt;type&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"report"&lt;/SPAN&gt;,        
       &lt;SPAN class=""&gt;tokenType&lt;/SPAN&gt;: models.&lt;SPAN class=""&gt;TokenType&lt;/SPAN&gt;.&lt;SPAN class=""&gt;Embed&lt;/SPAN&gt;,
       &lt;SPAN class=""&gt;filters&lt;/SPAN&gt;: [filter_user],
       &lt;SPAN class=""&gt;datasetBinding&lt;/SPAN&gt;: {
           &lt;SPAN class=""&gt;sourceDatasetId&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"67e095eb-0570-444f-a2c5-0c7b68f9ff85"&lt;/SPAN&gt;, # dataset
           &lt;SPAN class=""&gt;targetDatasetId&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"7a274ca6-7ed0-4bd1-a832-f9732f96164a"&lt;/SPAN&gt;  # dataset (test2)
       }
   };
 
   $.&lt;SPAN class=""&gt;ajax&lt;/SPAN&gt;({
       &lt;SPAN class=""&gt;type&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"GET"&lt;/SPAN&gt;,
       &lt;SPAN class=""&gt;url&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"/getembedinfo_filtered?report=06212621-c8cc-4153-a001-09c98ff2ceb4"&lt;/SPAN&gt;,
       &lt;SPAN class=""&gt;dataType&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"json"&lt;/SPAN&gt;,
       &lt;SPAN class=""&gt;success&lt;/SPAN&gt;: &lt;SPAN class=""&gt;function&lt;/SPAN&gt; (&lt;SPAN class=""&gt;data&lt;/SPAN&gt;) {
           &lt;SPAN class=""&gt;var&lt;/SPAN&gt; embedData = $.&lt;SPAN class=""&gt;parseJSON&lt;/SPAN&gt;(data);
           reportLoadConfig.&lt;SPAN class=""&gt;accessToken&lt;/SPAN&gt; = embedData.&lt;SPAN class=""&gt;accessToken&lt;/SPAN&gt;;
           reportLoadConfig[&lt;SPAN class=""&gt;"settings"&lt;/SPAN&gt;] = {
               &lt;SPAN class=""&gt;filterPaneEnabled&lt;/SPAN&gt;: &lt;SPAN class=""&gt;false&lt;/SPAN&gt;,
               &lt;SPAN class=""&gt;navContentPaneEnabled&lt;/SPAN&gt;: &lt;SPAN class=""&gt;true&lt;/SPAN&gt;
           };
 
           &lt;SPAN class=""&gt;// Embed Power BI report when Access token and Embed URL are available&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;var&lt;/SPAN&gt; report = powerbi.&lt;SPAN class=""&gt;embed&lt;/SPAN&gt;(reportContainer, reportLoadConfig);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I get an error "This content isn't available."&lt;/P&gt;&lt;P&gt;Embedding Error: {message: 'LoadReportFailed', detailedMessage: 'Get report failed', errorCode: '403', level: 6, technicalDetails: {…}}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 21:18:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Error-binding-a-dataset-dynamically-to-a-PowerBI-embedded-report/m-p/3975409#M53155</guid>
      <dc:creator>apoloduvalis</dc:creator>
      <dc:date>2024-06-05T21:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Error binding a dataset dynamically to a PowerBI embedded report</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Error-binding-a-dataset-dynamically-to-a-PowerBI-embedded-report/m-p/3976667#M53177</link>
      <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/216506"&gt;@apoloduvalis&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can check the official documentation below, which describes an error message similar to yours, which might be “Report ID doesn't match token”.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vyangliumsft_0-1717666045354.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1112254i7E008AB2B06A7BDC/image-size/large?v=v2&amp;amp;px=999" role="button" title="vyangliumsft_0-1717666045354.png" alt="vyangliumsft_0-1717666045354.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Refer to：&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/embedded/embedded-troubleshoot" target="_blank"&gt;Troubleshoot Power BI embedded analytics application - Power BI | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;As far as I know, the token is generated based on the DatasetID. When you use this token, it must match the DatasetID that was used to generate it. However, in your scenario, the DatasetID is dynamically switching. You need to ensure that the token you obtain matches the DatasetID you are currently using. If they do not match, it will result in an incorrect credential, leading to an error.&lt;/P&gt;
&lt;P&gt;You might consider creating two Configs. Use the corresponding Config for whichever report you need to use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the related document, you can view this content:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/troubleshoot-and-debug" target="_blank"&gt;How to troubleshoot and debug your embedding code in Power BI embedded analytics | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Developer/Token-expiring-in-Power-BI-embedded-error-403/m-p/1571976" target="_blank"&gt;Solved: Token expiring in Power BI embedded (error 403) - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 09:32:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Error-binding-a-dataset-dynamically-to-a-PowerBI-embedded-report/m-p/3976667#M53177</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-06T09:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Error binding a dataset dynamically to a PowerBI embedded report</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Error-binding-a-dataset-dynamically-to-a-PowerBI-embedded-report/m-p/3976699#M53179</link>
      <description>&lt;P&gt;How are you generating the embed token? Are you using this API&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi/embed-token/generate-token" target="_blank"&gt;Embed Token - Generate Token - REST API (Power BI Power BI REST APIs) | Microsoft Learn&lt;/A&gt;&amp;nbsp;? It's the newer way to generate a token, and it should be used when you intend to embed with dynamic binding.&lt;/P&gt;&lt;P&gt;Please make sure you specify the report ID, and relevant dataset IDs in the generate token request&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 09:49:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Error-binding-a-dataset-dynamically-to-a-PowerBI-embedded-report/m-p/3976699#M53179</guid>
      <dc:creator>AmosHersch</dc:creator>
      <dc:date>2024-06-06T09:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Error binding a dataset dynamically to a PowerBI embedded report</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Error-binding-a-dataset-dynamically-to-a-PowerBI-embedded-report/m-p/4002766#M53521</link>
      <description>&lt;P&gt;After several days banging my head against a wall, I figured out that I needed to call PowerBI API endpoint &lt;STRONG&gt;get_embed_params_for_multiple_reports&lt;/STRONG&gt; instead of &lt;STRONG&gt;get_embed_params_for_single_report&lt;/STRONG&gt; (the one in &lt;A href="https://github.com/microsoft/PowerBI-Developer-Samples/blob/master/Python/Embed%20for%20your%20customers/AppOwnsData/app.py" target="_blank" rel="noopener"&gt;the only complete example provided by Microsoft&lt;/A&gt;) to get the token that tells the service that the Javascript is already authenticated and authorized to use both the report and the new dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def getembedinfo_filtered(request):
    '''Returns Embed token and Embed URL for PowerBI reports in the embedded workspace'''
    report_id = request.GET['report']
    dataset_id = request.GET['dataset_id']

    pbi_config = set_parameters(report_id)
    service = PbiEmbedService(pbi_config)

    try:
        embed_token = service.get_embed_params_for_multiple_reports(
            settings.EMBEDDED_WORKSPACE_ID, [report_id], [dataset_id])
        embedinfo = {
            'accessToken': embed_token.accessToken,
            'tokenExpiry': embed_token.tokenExpiry,
            'embedUrl': embed_token.reportConfig[0]['embedUrl'],
        }
        return JsonResponse(embedinfo, safe=False)
    except Exception as e:
        return JsonResponse({'Error': str(e)}, status=400)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After solving the error with the authorization, then I had to deal with the javascript doing the embedding in the web app. The configuration object was wrong. The actual working code is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    var reportContainer = $(container_id).get(0);
    var reportId = reportContainer.dataset.reportId;
    var datasetId = reportContainer.dataset.datasetId;

    // Initialize iframe for embedding report
    powerbi.bootstrap(reportContainer, { type: "report" });

    var models = window["powerbi-client"].models;

    $.ajax({
        type: "GET",
        url: "/getembedinfo_filtered?report=" + reportId + "&amp;amp;dataset_id=" + datasetId,
        dataType: "json",
        success: function (data) {
            var reportLoadConfig = {
                type: "report",
                tokenType: models.TokenType.Embed,
                accessToken: data.accessToken,
                embedUrl: data.embedUrl,
                datasetBinding: {
                    datasetId: datasetId,
                },
                settings: {
                    filterPaneEnabled: false,
                    navContentPaneEnabled: true,
                }
            };

            // Embed Power BI report when Access token and Embed URL are available
            var report = powerbi.embed(reportContainer, reportLoadConfig);
        }
    })&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 20:14:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Error-binding-a-dataset-dynamically-to-a-PowerBI-embedded-report/m-p/4002766#M53521</guid>
      <dc:creator>apoloduvalis</dc:creator>
      <dc:date>2024-06-20T20:14:27Z</dc:date>
    </item>
  </channel>
</rss>

