Power BI answers 403 when a service principal queries a dataset
Your error
POST https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/executeQueries 403 (Forbidden)1 more line it can showFix it fast
Most common cause, 1 of 4Service principals are not allowed to call Power BI APIs in the tenant
Ask a Power BI admin to open Admin portal, Tenant settings, Developer settings, and enable Allow service principals to use Power BI APIs for the organization or for a security group.
# add the service principal to the allowed security group (Microsoft Graph PowerShell)
Connect-MgGraph -Scopes "Application.ReadWrite.All"
$sp = Get-MgServicePrincipal -Filter "AppId eq '<app-client-ID>'"
New-MgGroupMember -GroupId <security-group-object-id> -DirectoryObjectId $sp.IdShort answer
A 403 from the Power BI executeQueries API with a service principal token means Power BI knows the app but will not let it query. Check the Allow service principals to use Power BI APIs tenant setting, Member or Admin workspace access, the Dataset Execute Queries REST API setting, and whether the model uses RLS or SSO.
Which cause do you have?
Use the same token to list the workspaces the app can see, then list the datasets in the target workspace. A 401 or 403 here is cause 1; a missing workspace is cause 2; both lists working while executeQueries alone fails points to cause 3 or 4.
curl -s -H "Authorization: Bearer $TOKEN" https://api.powerbi.com/v1.0/myorg/groups
curl -s -H "Authorization: Bearer $TOKEN" https://api.powerbi.com/v1.0/myorg/groups/$GROUP_ID/datasetsThen find the line you see in this list and open its fix:
- 1Service principals are not allowed to call Power BI APIs in the tenant
Even GET /groups fails with the app's token, while the same calls work for a signed-in user - 2The service principal has no Member or Admin role on the workspace
GET /groups returns 200 but the workspace that holds the dataset is not in the list, or the dataset sits in someone's My workspace - 3The Dataset Execute Queries REST API tenant setting is off
Workspace and dataset lists work for the app, and only the executeQueries POST answers 403 - 4The model uses row-level security or SSO, which service principals cannot query
Everything above is in place, other datasets answer, and this one defines RLS roles or has SSO turned on
What does the error look like?
POST https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/executeQueries 403 (Forbidden)403 Forbidden
Cause 1 of 4
Service principals are not allowed to call Power BI APIs in the tenant
You seeEven GET /groups fails with the app's token, while the same calls work for a signed-in user
Check
The executeQueries 403 appears for every call when a Power BI admin has not turned on Allow service principals to use Power BI APIs under Developer settings. When the setting is limited to a security group, the app's service principal has to be a member of that group.
curl -s -o /dev/null -w "%{http_code}\n" -H "Authorization: Bearer $TOKEN" https://api.powerbi.com/v1.0/myorg/groupsFix
Ask a Power BI admin to open Admin portal, Tenant settings, Developer settings, and enable Allow service principals to use Power BI APIs for the organization or for a security group. If a group is used, add the service principal to it. Microsoft also advises leaving the Entra app with no Power BI API permissions configured, since they are never used and can cause confusing errors.
# add the service principal to the allowed security group (Microsoft Graph PowerShell)
Connect-MgGraph -Scopes "Application.ReadWrite.All"
$sp = Get-MgServicePrincipal -Filter "AppId eq '<app-client-ID>'"
New-MgGroupMember -GroupId <security-group-object-id> -DirectoryObjectId $sp.IdVerify
GET /groups now returns 200 with a JSON list for the app's token.
curl -s -H "Authorization: Bearer $TOKEN" https://api.powerbi.com/v1.0/myorg/groupsConfirmed by learn.microsoft.com
Cause 2 of 4
The service principal has no Member or Admin role on the workspace
You seeGET /groups returns 200 but the workspace that holds the dataset is not in the list, or the dataset sits in someone's My workspace
Check
An app can only reach semantic models in workspaces where it, or a security group it belongs to, holds the Member or Admin role. My workspace is not supported for service principals at all, so a dataset published there can never be queried this way.
curl -s -H "Authorization: Bearer $TOKEN" https://api.powerbi.com/v1.0/myorg/groups | grep -o '"name":"[^"]*"'Fix
In the Power BI service open the workspace, choose Workspace access, add the app (by its Entra display name) or its security group, and pick Member or Admin. Move any dataset out of My workspace into a shared workspace first.
# Power BI service: workspace > More > Workspace access > add the app or group > Member > AddVerify
The workspace appears in GET /groups and GET /groups/{groupId}/datasets lists the dataset.
curl -s -H "Authorization: Bearer $TOKEN" https://api.powerbi.com/v1.0/myorg/groups/$GROUP_ID/datasetsConfirmed by learn.microsoft.com
Cause 3 of 4
The Dataset Execute Queries REST API tenant setting is off
You seeWorkspace and dataset lists work for the app, and only the executeQueries POST answers 403
Check
Microsoft's API reference lists a separate requirement for this one call: the tenant setting Dataset Execute Queries REST API, under Integration settings, must be enabled, and the caller needs read and build permission on the dataset.
curl -s -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"queries":[{"query":"EVALUATE VALUES(MyTable)"}],"serializerSettings":{"includeNulls":true}}' \
https://api.powerbi.com/v1.0/myorg/datasets/$DATASET_ID/executeQueriesFix
Have a Power BI admin enable Dataset Execute Queries REST API under Integration settings (for everyone or for the app's security group). Then confirm the app holds read and build permission on that semantic model.
# Admin portal > Tenant settings > Integration settings > Dataset Execute Queries REST API > EnabledVerify
The same POST returns 200 with a results array holding your table rows.
curl -s -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{"queries":[{"query":"EVALUATE VALUES(MyTable)"}]}' https://api.powerbi.com/v1.0/myorg/datasets/$DATASET_ID/executeQueriesConfirmed by learn.microsoft.com
Cause 4 of 4
The model uses row-level security or SSO, which service principals cannot query
You seeEverything above is in place, other datasets answer, and this one defines RLS roles or has SSO turned on
Check
The Execute Queries reference states that, whatever the tenant settings say, service principals are not supported for datasets with RLS or with SSO enabled.
# open the semantic model in Power BI and look for row-level security roles or an SSO settingFix
Call the API with a delegated token from a real user who has read and build permission, so RLS can apply to that user, or query a copy of the model without RLS that is meant for the integration.
# acquire a delegated user token (scope Dataset.Read.All) and send the same executeQueries POSTVerify
The query returns 200 for the user token, with rows filtered by that user's roles.
curl -s -X POST -H "Authorization: Bearer $USER_TOKEN" -H "Content-Type: application/json" -d '{"queries":[{"query":"EVALUATE VALUES(MyTable)"}]}' https://api.powerbi.com/v1.0/myorg/datasets/$DATASET_ID/executeQueriesConfirmed by learn.microsoft.com
How do I stop it coming back?
- Put every Power BI integration app in one Entra security group and enable both tenant settings for that group only.
- Add the app to each workspace through the group, not one by one, so new workspaces get it in a single step.
- Record in the model's README whether it has RLS, so nobody wires a service principal to a model it cannot query.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.