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.
Hello Folks,
I hope you doing well, i'm trying to use this api
https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/getrefreshhistoryingroup
The demo mode rocks ! So it's cool but at the end of the day when i have create the app with all the right needed and when i try to use this api in Power BI i have the message : "Acces forbidden "
I have tried to :
Connect with Microsft Credidentials
Connect With Application ID
Connect With Application ID + token
I would like to know how to authentifacte for using this Api
Thanks a lot,
Regards,
Solved! Go to Solution.
Here is my code, see if you can spot any differences.
let
group = "d9db3715-2ae7-4aa1-aa44-xxx",
dataset = "9941f7c0-e07e-4382-959c-xxx",
auth = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOi-xxx",
Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/groups/" & group & "/datasets/" & dataset & "/refreshes", [Headers=[Authorization=auth]])),
value = Source[value],
#"Converted to Table" = Table.FromList(value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "refreshType", "startTime", "endTime", "status", "requestId", "serviceExceptionJson"}, {"id", "refreshType", "startTime", "endTime", "status", "requestId", "serviceExceptionJson"})
in
#"Expanded Column1"
I also use Anonymous as the login type.
@Urba34 , refer if these can help
https://windowsreport.com/access-to-resource-forbidden/
https://www.spguides.com/access-to-the-resource-is-forbidden-power-bi/
You are not saying what you are using to initiate the calls. Is this Powershell, Power Query, Power Automate?
Thanks for you quick reply
I'm using power query
Regards,
You can run your regular API calls in Power Query, like so :
let
Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/gateways/" & GatewayId & "/datasources", [Headers=[Authorization=Authorization]])),
value = Table.FromList(Source[value],Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(value, "Column1", {"id", "gatewayId", "datasourceType", "connectionDetails", "credentialType", "credentialDetails", "datasourceName"}, {"id", "gatewayId", "datasourceType", "connectionDetails", "credentialType", "credentialDetails", "datasourceName"}),
...
You can obtain the Authorization token manually (I usually just copy it from the API sandbox) or you can register an app and use the app's token.
OK thanks i will try this and give you a feedback thantks a lot !
Hi back,
I still have acces forbidden 😢 (see my screen below)
What i'm doing wrong ? What credentials i have to put ? I try Anonymous because all id comming from the url so .. idk
Thanks a lot 🙂
Regards,
Here is my code, see if you can spot any differences.
let
group = "d9db3715-2ae7-4aa1-aa44-xxx",
dataset = "9941f7c0-e07e-4382-959c-xxx",
auth = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOi-xxx",
Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/groups/" & group & "/datasets/" & dataset & "/refreshes", [Headers=[Authorization=auth]])),
value = Source[value],
#"Converted to Table" = Table.FromList(value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "refreshType", "startTime", "endTime", "status", "requestId", "serviceExceptionJson"}, {"id", "refreshType", "startTime", "endTime", "status", "requestId", "serviceExceptionJson"})
in
#"Expanded Column1"
I also use Anonymous as the login type.
It's WORKING !!!!!!!!
MAN YOU SAVE MY DAY !!
Thanks a lot ❤️
Good to hear. What I don't know (but would like to) is to how to harvest the auth token automatically from within the same Power Query script. I have tried many different things already but so far no luck. Any idea?
Sorry but i really don't know how to do that maybe with a loop ? or a Python Script ?
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.