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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
v-rzhou-msft
Community Support
Community Support

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
v-rzhou-msft
Community Support
Community Support

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 @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" 

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.