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
ArthurL
Regular Visitor

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 6
Jamir
Frequent Visitor

Helllo @ArthurL 

 

I have finally resolved my issue with postman calls, please have a look at resolution posted under below post.

 

https://community.powerbi.com/t5/Developer/How-to-get-EmbedToken-Generated-using-PostMan-HTTP-Error-...

 

 

 

ibarrau
Super User
Super 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,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Hello!
Thank you for your answer.
Their admin added app to workspaces, but I still get the error 401

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

OlivierVanheste_0-1660821683192.png

 


Kinds regards

Thank you for noticing that I used GET instead of POST.
But still error remains the same 401.
Next week I will have meeting with their BI admin and we will go step by step instruction to see what we missed.
I’ll update pos after that if managed to find something

Jamir
Frequent Visitor

@ArthurL 

 

Were you able to get resolution for this issue, I am having similar problem during generating EmbedToken, my post is below. For me somehow it is not able to reach the host and througing HTTP 400 Error

 

https://community.powerbi.com/t5/Developer/How-to-get-EmbedToken-Generated-using-PostMan-HTTP-Error-...

 

 

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.

Top Solution Authors
Top Kudoed Authors