Forum Discussion
Call dataset refresh with POSTMAN API call using client secret, please help
Hello!
I have problem trying to execute dataset refresh using POSTMAN api calls (for test purpose).
Clients POWER BI admin provided me with client id, tenant id, group id, dataset id and client secret.
The tenant settings in the Admin portal are enabled.
Now my actions:
First I generate Bearer token, using https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow as example
Method: post
url: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
headers: Content-Type: application/x-www-form-urlencoded
body:
client_id={clientId}
&client_secret={clientSecret}
&scope=https://analysis.windows.net/powerbi/api/.default
&grant_type=client_credentials
I get response 200 and token.
Then API call to refresh daset
Method: get
url: https://api.powerbi.com/v1.0/myorg/groups/{group_id}/datasets/{dataset-id}/refreshes
headers Authorization: Bearer {token}
But i get response 401 -
x-powerbi-error-info: | ServicePrincipalIsNotAllowedByTenantAdminSwitch |
I want to know if problem is from my side or something wasn’t done correctly while registering app in POWER BI or setuping in Azure.
If it is from my side were I did go wrong?
P.S. Client does not want to use login and password
6 Replies
- ibarrauSuper User
Hi! 401 means the accounts doesn't have the authority to make the action. That sounds like you haven't added the service principal to the workspace you are reaching to execute the refresh. (Admin or member, not viewer)
You also need to validate that the PowerBi Admin Portal tenant settings have the Service Principal usage of API enabled.
I guess one of those two might be the problem,
I hope that helps,
- ArthurLRegular Visitor
Hello!
Thank you for your answer.
Their admin added app to workspaces, but I still get the error 401- OlivierVanhesteRegular Visitor
Hi ArthurL ,
The documentation at Datasets - Refresh Dataset In Group - REST API (Power BI Power BI REST APIs) | Microsoft Docs It says that you need to use a POST request. In your original question, you say you use GET.
Further as suggested by ibarrau check if the "Allow service principals to use Power BI APIs" setting is enabled and that the service principal is added to the correct security group
Kinds regards