Forum Discussion

Zed101's avatar
Zed101
Frequent Visitor
3 years ago
Solved

Error: Generate token request for proxy model should include the core model ID

Trying to use RLS with PowerBi embedded analytics, when I tested a POST request to generate token:
POST https://api.powerbi.com/v1.0/myorg/GenerateToken

I'm receiving following error:

{ "error": { "code": "InvalidRequest", "message": "Generate token request for proxy model should include the core model ID" } }

This happens only in case when sending identities in request body for reports using direct query connection.

If it is expecting a "Core model Id" in such scenario, cannot understand what is core model Id and how to pass it in request body as request body doesn't mention anything like model or modelId.

For Request body structure, please see: 
https://learn.microsoft.com/en-us/rest/api/power-bi/embed-token/generate-token

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi,

     

    i was able to solve it.

     

    a report is using at least one dataset (= proxy model). If that dataset is referring to other datasets (= core model) then these need to be mentioned all in the generate embeded token request.

     

    eg

                                                            

    report1 -> dataset1 (proxy model) -> dataset2 (core model), dataset3 (core model)

     

    then the request should contain dataset1 id, dataset2 id and dataset3 id.

     

    these additional datasets (core models) should be added as a normal dataset (so a separate dataset object iso a modelid inside the existing one)

    {
    "accessLevel": "View",
    "allowSaveAs": "false",
    "datasetId": "<dataset ID>",
    "identities": [ ... ],
    "datasets": [
    {
    "id": "<dataset1 ID>",
    ...
    },{
    "id": "<dataset2 ID>",
    ...
    },{
    "id": "<dataset3 ID>",
    ...
    }
    ]
    }

     Hope this helps

     

    regards

10 Replies

  • jaweher899's avatar
    jaweher899
    Impactful Individual

    The "Core model ID" mentioned in the error message is a required parameter for generating a token when using row-level security (RLS) with direct query connections in Power BI Embedded. This parameter refers to the ID of the semantic model that the report is based on.

    To pass the Core model ID in the request body, you need to add a property called "datasets" to the JSON payload, which contains the list of datasets used in the report. For each dataset, you need to specify the dataset ID and the core model ID in the "id" and "modelId" properties, respectively.

    Here's an example of how to modify the request body to include the Core model ID:

     

    {
    "accessLevel": "View",
    "allowSaveAs": "false",
    "datasetId": "<dataset ID>",
    "identities": [ ... ],
    "datasets": [
    {
    "id": "<dataset ID>",
    "modelId": "<core model ID>"
    }
    ]
    }

     

    Replace <dataset ID> with the ID of the dataset used in the report, and <core model ID> with the ID of the semantic model that the report is based on.

    You can find the Core model ID by opening the report in Power BI Desktop and selecting "Modeling" from the ribbon. The Core model ID is displayed in the "Current File Properties" section.

    I hope this helps!

    • Zed101's avatar
      Zed101
      Frequent Visitor

      I tried it, receiving same error.
      I have only one dataset with xmlaPermissions set to ReadOnly, hence the request thus formed had a structure like below (Also, replaced all placeholders below with real values)

       

      {
      "accessLevel": "View",
      "allowSaveAs": "false",
      "datasetId": "<dataset ID>",
      "identities": [ 

      {
      "username": "<userName>",
      "roles": [
      "Default"
      ],
      "datasets": [
      "<dataset ID>"
      ]
      }

      ],
      "datasets": [
      {
      "id": "<dataset ID>",
      "modelId": "<core model ID>",

      "xmlaPermissions": "ReadOnly"
      }
      ]
      }


      I was able to find the modelId, however passing it into the request the way as suggested above didn't work for me. Also, if you could examine the request structure for datasets array inside from https://learn.microsoft.com/en-us/rest/api/power-bi/embed-token/generate-token#generatetokenrequestv2dataset, you'd see there is no mention of modelId there. Still I tried but didn't work.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

     

    any updates on how to solve this? Where can we find the core model id?

     

    regards,

     

    PJ

    • Zed101's avatar
      Zed101
      Frequent Visitor

      Hi, 

      No luck so far. The actual problem is how to pass modelId to the request. 
      You can see modelId in browser while report is loading under Network tab:

      So you can find modelId through either conceptual schema or models&Exploration request.  


      But, can't proceed any further.

      BR

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi,

         

        i was able to solve it.

         

        a report is using at least one dataset (= proxy model). If that dataset is referring to other datasets (= core model) then these need to be mentioned all in the generate embeded token request.

         

        eg

                                                                

        report1 -> dataset1 (proxy model) -> dataset2 (core model), dataset3 (core model)

         

        then the request should contain dataset1 id, dataset2 id and dataset3 id.

         

        these additional datasets (core models) should be added as a normal dataset (so a separate dataset object iso a modelid inside the existing one)

        {
        "accessLevel": "View",
        "allowSaveAs": "false",
        "datasetId": "<dataset ID>",
        "identities": [ ... ],
        "datasets": [
        {
        "id": "<dataset1 ID>",
        ...
        },{
        "id": "<dataset2 ID>",
        ...
        },{
        "id": "<dataset3 ID>",
        ...
        }
        ]
        }

         Hope this helps

         

        regards