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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
DucJanssens
Regular Visitor

PowerBI entity cannot be found when RLS-enabled viewer runs query via API

Hi, 

 

We're running into an issue we were hoping you would be able to assist with. 

In PowerBI we have the following table, named MONTHLYDATA: 

DateClientField1Field2Field3Field4
01-01-2024A1111
01-01-2024B2222
01-01-2024C333

 

We want to expose this data via API, namely via the POST https://api.powerbi.com/v1.0/myorg/groups/{{group-id}}/datasets/{{-dataset-id}}/executeQueries endpoint.

 

This table contains data of multiple different clients. We want those clients to access their data, and ONLY their data. As such, we've set up a proof of concept where we have enabled RLS (Row-level security) in PowerBI desktop on this table, where RoleA on this filter may only access rows where Client = A. Consequently, in the browser app we've assigned a test user directly to RoleA. This test user's account has also been directly onboarded in the workspace, in the viewer role. 

 

In the browser app of PowerBI this works, in the sense that in the report the user can only view the row with Client = A. The semantic model cannot be viewed at all.

However, if we try to call the above API, using a valid bearer token and the following POST body:

 

 

 

{
  "queries": [
    {
      "query": "EVALUATE VALUES(MONTHLYDATA)"
    }
  ]
}

 

 

 

 We're getting a 404 Not found with the following response body: 

 

 

 

{
    "error": {
        "code": "PowerBIEntityNotFound",
        "pbi.error": {
            "code": "PowerBIEntityNotFound",
            "parameters": {},
            "details": [
                {
                    "code": "DetailsMessage",
                    "detail": {
                        "type": 1,
                        "value": "You cannot query the dataset '{{dataset-id}}' by using the REST API because the dataset was not found or you do not have the required permissions. Please contact a workspace admin or a dataset owner to grant you the required permissions. See https://go.microsoft.com/fwlink/?linkid=2190204 for more info on required permissions."
                    }
                }
            ]
        }
    }
}

 

 

 

 

We've tried adding an impersonatedUserName to the body as well, without success. 

If we remove the user from the role, but leave the rest as is, then the endpoint will again return all data in the table above, so as far as we know the scopes have been set correctly (this is also seen in the token, since Dataset.Read.All is present under scp). 

 

The documentation on this subject:

https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/execute-queries

https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/execute-queries-in-group

https://learn.microsoft.com/en-us/power-bi/connect-data/service-datasets-manage-access-permissions

https://learn.microsoft.com/en-us/power-bi/developer/embedded/datasets-permissions#row-level-securit...

 

Indicates that enabling RLS in the API should be possible. According to the semantic model settings of the semantic model where MONTHLYDATA is part of, the user in question has Workspace Viewer access.

 

Our question is now: what are we missing? And is it even possible to enable RLS via the API?

 

Many thanks in advance.

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

Thanks for the reply from lbendlin , please allow me to provide another insight: 
Hi  @DucJanssens ,

 

Based on the error message returned when you executing the API, it seems you met the permission error, could you please first check if you are able to meet the permission requirement of the API documentation, thanks in advance.

Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Learn

 

The tenant setting Dataset Execute Queries REST API, found under Integration settings, must be enabled.

The user must have dataset read and build permissions. For more information, see Manage dataset access permissions.

 

Best Regards,

Liu Yang

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
v-yangliu-msft
Community Support
Community Support

Thanks for the reply from lbendlin , please allow me to provide another insight: 
Hi  @DucJanssens ,

 

Based on the error message returned when you executing the API, it seems you met the permission error, could you please first check if you are able to meet the permission requirement of the API documentation, thanks in advance.

Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Learn

 

The tenant setting Dataset Execute Queries REST API, found under Integration settings, must be enabled.

The user must have dataset read and build permissions. For more information, see Manage dataset access permissions.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

which user is calling the API endpoint? 

Hi, that would be the same test user as mentioned. He's directly authorized in Power BI, but also Power BI is registered to Entra ID, so the authentication for the API happens via Entra ID. We've verified that there are no access problems here, since the test user can retrieve a response from the API using a valid bearer token from Entra ID if he is not onboarded in the role in Power BI.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.