Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi All
I have BMC Remedy API and trying to consume it to show data in dashboard.
I am followwing below vedio but no luck as I am not sure from where I can generate Bearer token. Also I am not sure there are different ways to consume on-premise API and cloud APIs .
https://www.youtube.com/watch?v=N8qYRSqRz84 ,
Please help me to understand how can I consume the api in Power BI.
Solved! Go to Solution.
Hi @Vinaysingh115 ,
Firstly, we need to get Access token in Power BI Desktop. We will get access token from Power BI by below code.
() =>
let
body = "client_id=" & #"App ID"
& "&scope=https://analysis.windows.net/powerbi/api/.default&client_secret=" & #"App Secret"
& "&grant_type=client_credentials",
Data= Json.Document(Web.Contents("https://login.microsoftonline.com/"& TenantID & "/oauth2/v2.0/token/",
[Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body)])),
access_token = Data[access_token]
in
access_token
OR
() =>
let
body = "&grant_type=Password&resource = https://analysis.windows.net/powerbi/api
&client_id=*****&username=*****&password=*****",
Data=Json.Document(Web.Contents("https://login.microsoftonline.com/common/oauth2/v2.0/token/",
[Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body)])),
access_token = Data[access_token]
in
access_token
Then you can follow your video above to get data from the Rest API by access token in first step.
Finally, you can replace bear token by the access token parameter.
It will refresh every time your refresh your report.
Video: How to get access token and call Rest API by dynamic access token in Power BI Desktop? (5:30 to 9:30)
all Power BI Rest API with Dynamic Access Token From Power BI Desktop |Power BI Rest API
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Vinaysingh115 ,
Firstly, we need to get Access token in Power BI Desktop. We will get access token from Power BI by below code.
() =>
let
body = "client_id=" & #"App ID"
& "&scope=https://analysis.windows.net/powerbi/api/.default&client_secret=" & #"App Secret"
& "&grant_type=client_credentials",
Data= Json.Document(Web.Contents("https://login.microsoftonline.com/"& TenantID & "/oauth2/v2.0/token/",
[Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body)])),
access_token = Data[access_token]
in
access_token
OR
() =>
let
body = "&grant_type=Password&resource = https://analysis.windows.net/powerbi/api
&client_id=*****&username=*****&password=*****",
Data=Json.Document(Web.Contents("https://login.microsoftonline.com/common/oauth2/v2.0/token/",
[Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body)])),
access_token = Data[access_token]
in
access_token
Then you can follow your video above to get data from the Rest API by access token in first step.
Finally, you can replace bear token by the access token parameter.
It will refresh every time your refresh your report.
Video: How to get access token and call Rest API by dynamic access token in Power BI Desktop? (5:30 to 9:30)
all Power BI Rest API with Dynamic Access Token From Power BI Desktop |Power BI Rest API
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-rzhou-msft ,
I am new to Power BI . Can you please let me know where I need to put the code you have mentioned in Power BI to generate access token .
Thanks.
Hi @Vinaysingh115 ,
Click on "Transform data"
-> Right Click in Queries -> Select "Blank Query" in New Query
->Click on Advanced Editor
-> Copy and paste your code into Advanced Editor. Note: You need to replace parameters like "Client_ID" by correct ID.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
15 | |
4 | |
2 | |
1 | |
1 |
User | Count |
---|---|
21 | |
3 | |
2 | |
2 | |
2 |