Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hi ,
I'd like to use python to connect PBI sementic models.
And I created a REST API, a security group, and the REST API is the member of secutity group.
The REST API and secutity group are the members of the PBI workspace as well.
I am sure that the tenant ID, client ID of the rest API, the workspace ID and dataset ID are correct and this is no RLS in the dataset and we enable the related settings in PBI workspace.
But when I try to get data from the dataset, it posts a error,
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: Additional information from API: {'error': {'code': 'DatasetExecuteQueriesError', 'pbi.error': {'code': 'DatasetExecuteQueriesError', 'parameters': {}, 'details': [{'code': 'DetailsMessage', 'detail': {'type': 1, 'value': 'Failed to open the MSOLAP connection.'}}, {'code': 'AnalysisServicesErrorCode', 'detail': {'type': 1, 'value': '0'}}]}}}
Any help would be much appreciated, thank you.
Solved! Go to Solution.
Hi @yeliu_yl
The error “Failed to open the MSOLAP connection” when using Python to query a Power BI semantic model via the REST API generally indicates that the service principal (REST API app registration) doesn’t have sufficient permissions or the correct authentication path to access the XMLA endpoint of the dataset. Even though your app and security group are correctly added to the workspace and the tenant, Power BI enforces additional restrictions when connecting programmatically to semantic models—especially for datasets hosted in Premium Per User (PPU) or Fabric capacities. The service principal must be explicitly granted “Dataset Read” or “Dataset Build” permissions and must have service principal access enabled at both the tenant level (under Admin Portal → Tenant Settings → Developer settings → “Allow service principals to use Power BI APIs”) and at the workspace level (“Allow XMLA read/write” must be enabled). In many cases, this error occurs because the semantic model resides in a PPU workspace, which does not support XMLA connections from external tools or service principals using MSOLAP. To fix this, move the dataset to a Premium (Fabric) capacity workspace or use a user account token (delegated authentication) instead of the service principal for testing. Once in a supported workspace type and with permissions verified, your Python connection using the REST API should successfully open the MSOLAP connection and execute queries.
Hi @yeliu_yl,
Thank you for reaching out to Microsoft Fabric Community.
Thank you @Poojara_D12 and @GilbertQ for the prompt response.
Since fabric notebooks are disabled in your environment, please follow below approaches:
If your workspace is on Premium or Fabric capacity and the right settings are enabled, the python connection should work.
If it is in PPU or the admin has disabled service principal access, you will need to connect using a user account token. These are the supported approaches.
Thanks and regards,
Anjan Kumar Chippa
Thank you all, It works now~😊
Hi @yeliu_yl
Why don't you use the Semantic Link Labs which has got all the path and libraries already installed, allowing you to connect to your semantic model? Here are more details. microsoft/semantic-link-labs: Early access to new features for Microsoft Fabric's Semantic Link.
How to run a DAX query
sempy_labs package — semantic-link-labs 0.12.4 documentation
Fabric notebook is disabled by our admin, it's unable to be used in my workspace.
Hi @yeliu_yl,
Thank you for reaching out to Microsoft Fabric Community.
Thank you @Poojara_D12 and @GilbertQ for the prompt response.
Since fabric notebooks are disabled in your environment, please follow below approaches:
If your workspace is on Premium or Fabric capacity and the right settings are enabled, the python connection should work.
If it is in PPU or the admin has disabled service principal access, you will need to connect using a user account token. These are the supported approaches.
Thanks and regards,
Anjan Kumar Chippa
Hi @yeliu_yl
The error “Failed to open the MSOLAP connection” when using Python to query a Power BI semantic model via the REST API generally indicates that the service principal (REST API app registration) doesn’t have sufficient permissions or the correct authentication path to access the XMLA endpoint of the dataset. Even though your app and security group are correctly added to the workspace and the tenant, Power BI enforces additional restrictions when connecting programmatically to semantic models—especially for datasets hosted in Premium Per User (PPU) or Fabric capacities. The service principal must be explicitly granted “Dataset Read” or “Dataset Build” permissions and must have service principal access enabled at both the tenant level (under Admin Portal → Tenant Settings → Developer settings → “Allow service principals to use Power BI APIs”) and at the workspace level (“Allow XMLA read/write” must be enabled). In many cases, this error occurs because the semantic model resides in a PPU workspace, which does not support XMLA connections from external tools or service principals using MSOLAP. To fix this, move the dataset to a Premium (Fabric) capacity workspace or use a user account token (delegated authentication) instead of the service principal for testing. Once in a supported workspace type and with permissions verified, your Python connection using the REST API should successfully open the MSOLAP connection and execute queries.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.