Forum Discussion
Power BI REST API response 401
- 2 years ago
Hi,
the app registration does not need any permissions.
- To retrieve the token, you'd use the URL https://login.microsoftonline.com/{tenant ID}/oauth2/v2.0/token
- Did you add the app registration as workspace admin member in the workspace you specify?
- Is the app registration (service principal) allowed to connect in PowerBI tenant setting "Allow Service Principals to use PowerBI API "
- Also check that tenant setting "Dataset Execute Queries REST API" is enabled
I wrote just a similar article about it here, using the PowerBI API from ADF (but works teh same for Python, Postman, or other client) : Use Power BI APIs from Azure Data Factory - Mattias De Smet
It should be a v2 workspace, but I believe all workspaces have been converted to v2 now.
The app registration should be available to select as a member to the workspace when you press "manage access" in the workspace.
Hi mattiasdesmet , thank you for your help. I did a little more digging and contacted my support department. It seems that I didn't have the proper rights within the Power BI tenant. All 4 bullets are now enabled. That means that the app is now a workspace admin. And the two settings in the Power BI tenant settings are now enabled. It also seems that the app needed to be verified by my Azure tenant admin. When it was verified, I could add it to the workspace as admin.
When running my code now, I am getting a <Response [200]>, but the response is empty for the rest. Using my groupid of the workspace I added the app to as admin. I don't get this because this API call should return all reports which are in the workspace?
https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports- mattiasdesmet2 years agoResolver II
That seems to be configured correctly and a Reponse 200 also indicates Status OK from the rest call.
The best way to check if this is something with the API or the python script to me is to try this out in Postman. One request to get the token and another to run the rest call.
The body should now contain a result like (which I just tested with the call /reports you mentioned)
{"@odata.context": "http://wabi-north-europe-g-primary-redirect.analysis.windows.net/v1.0/myorg/groups/cxxxxx/$metadata#reports","value": [{"id": "xxxxxx","reportType": "PowerBIReport","name": "Trace","embedUrl": ".....","isFromPbix": true,"isOwnedByMe": true,"datasetId": "xxxxx","datasetWorkspaceId": "xxxxx","users": [],"subscriptions": []},....- Vinnie2 years agoHelper I
Hi mattiasdesmet , this is now working. I forgot the 'f' at this line:
It didn't send the groupid to the API call.Thank you so much for your help. It is working now! I get the proper response.