Forum Discussion

safrasmusthafa's avatar
safrasmusthafa
Frequent Visitor
6 months ago
Solved

DAX standalone query execution using python

Hi, iwanted to execute DAX query through service principal in python standalone (vsCOde). but i got the error as below. Status Code: 401 {"error":{"code":"PowerBINotAuthorizedException","pbi.erro...
  • v-karpurapud's avatar
    6 months ago

    Hi safrasmusthafa 

    Thank you for sharing the updated configuration and Python code. Even though the service principal has tenant‑level access, is added to the workspace, and the workspace is running on Fabric (F2) capacity, the 401 PowerBINotAuthorizedException occurs because the REST API executeQueries endpoint does not support DAX execution when using a service principal. In Premium/Fabric workspaces, service principals can run DAX only through the workspace’s XMLA endpoint (powerbi://...), as XMLA is the only interface that accepts application‑only authentication for DAX operations. To execute DAX from Python, you will need to use an XMLA‑compatible client library (such as pyadomd) and authenticate using the client‑credentials OAuth flow with your tenant ID, client ID, and client secret. Once connected through the XMLA endpoint, the service principal will have the necessary authorization to run standalone DAX queries successfully.

    Regards,

    Microsoft Fabric Community Support Team.