Forum Discussion
Trying to query data with python scripts using power bi rest api
i was trying to access one of the dataset pubhlished in workspace through power bi rest api where i have admin privileges.The error recieved is "403".
Below mentioned is the code used to excute the query.
Please help me to fix the issue
You’re getting 403 because you’re using an embed token — that only works for embedding, not for REST API queries.
Fix: Use an Azure AD access token (via MSAL) with scope
https://analysis.windows.net/powerbi/api/.defaultThen call executeQueries directly with that token.
Remove the GenerateToken step.
2 Replies
- GilbertQ
Super User
Hi Arya_A_R
I would highly recommend using Semantic Link Labs which will make it a lot easier to get your daxquery results. Here is a link where you can start. Code Examples · microsoft/semantic-link-labs Wiki
And here is the command to run the DAX query: sempy_labs package — semantic-link-labs 0.11.3 documentation
- Shahid12523
Community Champion
You’re getting 403 because you’re using an embed token — that only works for embedding, not for REST API queries.
Fix: Use an Azure AD access token (via MSAL) with scope
https://analysis.windows.net/powerbi/api/.defaultThen call executeQueries directly with that token.
Remove the GenerateToken step.