Forum Discussion
REST API - got a token, but when using it, call returns 401 unauthorized
Hi Guys,
I was trying to solve my problem by using information form similiar threads on this forum, but can't find an answer there.
I'm trying to call the REST API to refresh a PowerBI dataset from Postman (this will be used later in Azure Data Factory). I've:
1. Registered an app (type: Web app / API) using https://dev.powerbi.com/apps
2. Got the grant of the admin for dataset view and read/write
3. Got the token call to work - I receive the bearer token
And now when I call the api with the below link, I get 401 unouthorized. Is there anything I might be missing there?
https://api.powerbi.com/v1.0/myorg/datasets/HERE_I_PUT_MY_DATASET/refreshes
Regards,
Andy
4 Replies
- v-juanli-msftCommunity Support
Hi Anonymous
Could you show the detailed error message?
Like
Error Message: The remote server returned an error: (401) Unauthorized. Stack Trace:
****According to this article, to trigger a refresh for the specified dataset from the specified workspace, you could use the following code:
POST https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetKey}/refreshesIn addition, Please check if you are able to refresh the dataset from Power BI.
Go to Azure Active Directory find the powerbi application to check if you have the permission to refresh.
Best Regards
Maggie
- AnonymousNot applicable
Hello Maggie,
Thanks for the quick reply!
The error message I get is: image
I took the trigger from https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/refreshdataset . Now I've tried with the group also, the issue is still the same. I know it's a problem with the permissions, because I get 403 if I provide wrong token, and I get "token expired" if it's too old.
I'm able to refresh it manually, I do it very often. But I'm gettimng the token with client_credentials, so probably the permisions are not passed from my account, but from the app registration. And my app has the Dataset.ReadWrite.All granted by the admin. :(
Regards,
Andy
- AnonymousNot applicable
Hello Andy!
I encountered the same issue. I even tried to use https://github.com/microsoft/PowerBI-Developer-Samples but after filling the credentials I also get 401 error. Did you rmanage to esolve this issue?