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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
yeliu_yl
New Member

Get Help with PBI - Failed to open the MSOLAP connection

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. 

2 ACCEPTED SOLUTIONS
Poojara_D12
Super User
Super User

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.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

View solution in original post

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:

  • Make the dataset accessible to your service principal by placing it in a Premium or Fabric workspace and make sure XMLA and service principal access are enabled.
  • If that is not possible, connect using a delegated user token instead of the service principal.

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

View solution in original post

5 REPLIES 5
yeliu_yl
New Member

Thank you all, It works now~😊

GilbertQ
Super User
Super User

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 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

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:

  • Make the dataset accessible to your service principal by placing it in a Premium or Fabric workspace and make sure XMLA and service principal access are enabled.
  • If that is not possible, connect using a delegated user token instead of the service principal.

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

Poojara_D12
Super User
Super User

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.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.