Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Power bi Refresh API service principle

Trying to build a step into my data pipeline that could refresh the power bi report. I have made it to this far that my AAD Client ID triggers the refresh, but it always asks my personal password, plus the mfa. Is there a way to use a service principale or something that wouldn't require a personal password?

 

 

 

 

 

5 REPLIES 5
Jayendran
Solution Sage
Solution Sage

Hi @Anonymous ,

 

Yes you can use the Service principal to call the Refresh API

 

POST https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}/refreshes

But before you call the refresh API the SPN needs to takeover the dataset, for that you can call the below API

 

POST https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}/Default.TakeOver

All the above API needs to call using the SPN credentials.

 

 

Anonymous
Not applicable

Thanks for getting back to me. How did you do the authentication? 

Anonymous
Not applicable

Maybe this can give you an idea: https://docs.microsoft.com/en-us/power-bi/developer/get-azuread-access-token#access-token-with-servi...

 

I can't  explain more without knowing  how you're implementing this. 

I'm using the Power BI Nuget package to perform changes like yours using the Service Principal. I tried using Postman but I couldn't get the AAD token: "AADSTS500011: The resource principal named https://analysis.windows.net/powerbi/api/ was not found in the tenant named .... This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant

Anonymous
Not applicable

The implementaions goes like that: I have a personal account(Pro Lincence, which creates the native app). According to this https://docs.microsoft.com/en-us/power-bi/developer/embed-service-principal#get-started-with-a-servi...

Couldn't get the token, so now we will make a user which has no MFA and will work as a technical user, which is not good practice. We still use sp to access keyvault to get the credentials. 

This is like a endless circle 🙃 

Hi there,

When you tried using your pro ACC for authentication its not a spn approach

In order to get the spn you can use the below method ,the same for postman too.

p_url = 'https://login.microsoftonline.com/' + 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' + '/oauth2/token'
data = { 'grant_type':'client_credentials',
'client_id': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
'client_secret': 'L------------------------------------------=',
'resource':'https://analysis.windows.net/powerbi/api' }
r = requests.post(url=p_url, data=data)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.