Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Databases and Redis

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 show

Fix it fast

Most common cause, 1 of 4

Service 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.

Fix
# 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.Id
Did this fix it?
Full steps for this cause: check, fix, verify

Short 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.

  • Applies to Power BI REST API v1.0 (Datasets - Execute Queries), Microsoft Entra ID app with client secret
  • Updated
  • By Maaz Zindani, Senior Software Engineer

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.

Run this first
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/datasets

Then find the line you see in this list and open its fix:

  1. 1Service principals are not allowed to call Power BI APIs in the tenantEven GET /groups fails with the app's token, while the same calls work for a signed-in user
  2. 2The service principal has no Member or Admin role on the workspaceGET /groups returns 200 but the workspace that holds the dataset is not in the list, or the dataset sits in someone's My workspace
  3. 3The Dataset Execute Queries REST API tenant setting is offWorkspace and dataset lists work for the app, and only the executeQueries POST answers 403
  4. 4The model uses row-level security or SSO, which service principals cannot queryEverything 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.

Check
curl -s -o /dev/null -w "%{http_code}\n" -H "Authorization: Bearer $TOKEN" https://api.powerbi.com/v1.0/myorg/groups

Fix

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.

Fix
# 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.Id

Verify

GET /groups now returns 200 with a JSON list for the app's token.

Verify
curl -s -H "Authorization: Bearer $TOKEN" https://api.powerbi.com/v1.0/myorg/groups

Confirmed by learn.microsoft.com

Did this fix it?

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.

Check
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.

Fix
# Power BI service: workspace > More > Workspace access > add the app or group > Member > Add

Verify

The workspace appears in GET /groups and GET /groups/{groupId}/datasets lists the dataset.

Verify
curl -s -H "Authorization: Bearer $TOKEN" https://api.powerbi.com/v1.0/myorg/groups/$GROUP_ID/datasets

Confirmed by learn.microsoft.com

Did this fix it?

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.

Check
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/executeQueries

Fix

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.

Fix
# Admin portal > Tenant settings > Integration settings > Dataset Execute Queries REST API > Enabled

Verify

The same POST returns 200 with a results array holding your table rows.

Verify
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/executeQueries

Confirmed by learn.microsoft.com

Did this fix it?

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.

Check
# open the semantic model in Power BI and look for row-level security roles or an SSO setting

Fix

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.

Fix
# acquire a delegated user token (scope Dataset.Read.All) and send the same executeQueries POST

Verify

The query returns 200 for the user token, with rows filtered by that user's roles.

Verify
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/executeQueries

Confirmed by learn.microsoft.com

Did this fix it?

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.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.