Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Vinaysingh115
Frequent Visitor

Unable to connect API

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.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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.

RicoZhou_0-1653637638160.png

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.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

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.

RicoZhou_0-1653637638160.png

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 @Anonymous ,

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.

Anonymous
Not applicable

Hi @Vinaysingh115 ,

 

Click on "Transform data" 

RicoZhou_0-1653875259233.png

-> Right Click in Queries -> Select "Blank Query" in New Query

RicoZhou_1-1653875267166.png

->Click on Advanced Editor

RicoZhou_2-1653875282217.png

-> Copy and paste your code into Advanced Editor. Note: You need to replace parameters like "Client_ID" by correct ID.

RicoZhou_3-1653875288677.png

 

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.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.