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.
Hi All,
I am currently working on PowerBI integration. I have set-up an application and granted access to the PowerBI Service APIs.
But after getting the access token, I get a 403 when I try to call https://api.powerbi.com/v1.0/myorg/datasets
Here is my sample code:
String datasetJson = "{\"name\": \"Sales101\", \"tables\": " +
"[{\"name\": \"Product\", \"columns\": " +
"[{ \"name\": \"ProductID\", \"dataType\": \"Int64\"}, " +
"{ \"name\": \"Name\", \"dataType\": \"string\"}, " +
"{ \"name\": \"Category\", \"dataType\": \"string\"}," +
"{ \"name\": \"IsCompete\", \"dataType\": \"bool\"}," +
"{ \"name\": \"ManufacturedOn\", \"dataType\": \"DateTime\"}" +
"]}]}";
OkHttpClient client = new OkHttpClient.Builder()
.followRedirects(false)
.build();
RequestBody formBody = RequestBody.create(MediaType.parse("application/json"), datasetJson);
Request request = new Request.Builder().addHeader("Authorization", String.format("Bearer {0}", accessToken))
.url("https://api.powerbi.com/v1.0/myorg/datasets")
.post(formBody)
.build();
Call call = client.newCall(request);
okhttp3.Response response = call.execute();
Please note that my access token seem to have the right permissions. Please see below excerpt when I decoded my JWT:
"scp": "App.Read.All Capacity.Read.All Capacity.ReadWrite.All Content.Create Dashboard.Read.All Dashboard.ReadWrite.All Dataflow.Read.All Dataflow.ReadWrite.All Dataset.Read.All Dataset.ReadWrite.All Gateway.Read.All Gateway.ReadWrite.All Report.Read.All Report.ReadWrite.All StorageAccount.Read.All StorageAccount.ReadWrite.All Tenant.Read.All Tenant.ReadWrite.All Workspace.Read.All Workspace.ReadWrite.All",
Also, please note that I am a normal PowerBI user. To use the APIs.. . I did the following:
- Created a new app with client Id and Secret
- Set-up the right permissions for APIs
I didn't do any changes on PowerBI... I assume the API permissions are enough?
Guidance is extremely appreciated.
Solved! Go to Solution.
this is resolved. The problem was with the String.format function I was using. The token wasn't being passed.
this is resolved. The problem was with the String.format function I was using. The token wasn't being passed.
What happens when you do a dry run on the API website?
https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/getdatasets
click the "try it" button.
Hi @lbendlin The dry run works and I am able to push the dataset. But, I think the Try button uses a predefined cllient and impersonator scope. I am not sure what is it that I am doing wrong
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.