Forum Discussion
403 error message while trying to hit PBI API (I am able to get the token)
- 4 years ago
The AAD token you are generating in
GetServicePrincipalToken
is not set with the right audience
make sure the token you are using is with the right audience for powerbi API's "https://analysis.windows.net/powerbi/api"
1. Did you manage to make any other calls to PowerBI with the specified App
For example try to call
https://docs.microsoft.com/en-us/rest/api/power-bi/groups/create-group
If not that could indicate some miss configuration os your app or the aquired token
2. Try to enable the Profiles feature to the entire org and see if that solve the problem
3. If issue still not resolved then add the requestId from the Create Profile API 403 reponse to this thread so we can try track the failure
- Anonymous4 years agoNot applicable
Hi! Thanks for the response
first, I want to check. Can I use the Service principal and the API with PPU or do I need premium capacity?
I turned all 3 settings to "The entire organization"
I send the request below and got the 403. I also tried using postman
Request ID: 88398de2-d060-4b65-997d-a821d44f36c4
(got the ID from Postman, not using the code below)
import requests import json from config import APIParam from GetServicePrincipalToken import GetServicePrincipalToken token = GetServicePrincipalToken(APIParam['TenantID'],APIParam['ClientID'],APIParam['ClientSecret']) api_url = "https://api.powerbi.com/v1.0/myorg/groups?workspaceV2=True" headers = {"Authorization": f"Bearer {token}"} payload = {"name": "Sample workspace V2"} response = requests.request("POST",api_url, json=payload, headers=headers) #response = json.loads(response.text) print(response)