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
Anonymous
Not applicable

How to configure Power BI REST API as a data source

Good day,

 

I was recently searching for ways how to include the refresh history in a report and got introduced to the Power BI REST APIs. After playing with the "Try it" function on Microsoft's website I realised this is exactly what I need. I can build a URL using the group and dataset ID, which returns the refresh history as a JSON. 

 

Here is an example of what the URL looks like:

https://api.powerbi.com/v1.0/myorg/groups/group_id/datasets/dataset_id/refreshes

 

Is it possible to configure the API as a datasource in Power BI? I tried passing the URL as a Web source, but cannot authenticate with either my Windows or Organisational account.

 

Some forums suggested that I need an Azure app to facilitate the authentication. An app has been registered on the Azure portal and I have the application ID/ token ID/ secret value but I'm not sure how to use this to configure an API call as a data source.

 

Any help would be appreciated!

Regards

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous,

 

You can just use this code to get data from REST API in power query:

 

let
    Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/groups/{group id}/datasets/{datasetid}", [Headers=[Authorization="Bearer ************"]])),
    value = Source[value],
    value1 = value{0}
in
    value1

 

result:

vchenwuzmsft_1-1639713413314.png

 

But you should first get the Authorization code. you can use Request URL ID to generate Access Token.

And you can refer this article to get data from REST API.

https://www.sqlshack.com/how-to-access-power-bi-rest-apis-programmatically/ 

 

Best Regards

Community Support Team _ chenwu zhu

 

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-chenwuz-msft
Community Support
Community Support

Hi @Anonymous,

 

You can just use this code to get data from REST API in power query:

 

let
    Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/groups/{group id}/datasets/{datasetid}", [Headers=[Authorization="Bearer ************"]])),
    value = Source[value],
    value1 = value{0}
in
    value1

 

result:

vchenwuzmsft_1-1639713413314.png

 

But you should first get the Authorization code. you can use Request URL ID to generate Access Token.

And you can refer this article to get data from REST API.

https://www.sqlshack.com/how-to-access-power-bi-rest-apis-programmatically/ 

 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Anonymous
Not applicable

Thank you @v-chenwuz-msft for your inputs.

 

I tried setting up the datasource as suggested and got the following message:

 

WJWest_1-1639724078344.png

 

Did I do something wrong in power query or is it not accepting the access token?

Hi @Anonymous ,

 

I get the same error message  just now, i edit the permission as anonymous .

vchenwuzmsft_0-1639727692912.png

 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

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.

Top Solution Authors