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

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.

Reply
sjc4062
Frequent Visitor

Power Bi API as a Data Source in Power Bi

Good Afternoon,

I am attempting to connect to the Power BI API to use it as a data source within Power BI. The goal of this is to be able to get a complete of last refreshed dates and owners of all the reports in environemnt (If there is a better way to do this i am open to suggestions)

 

So i am able to connect to "https://login.windows.net/common/oauth2/token",  to get my bearer token ( i can provide the entire query if needed)

At this point i can save this report and upload it to powerbi.com and it can be scheduled for refresh with no issues.

 

I then attempt to add the second part of the query, pulling the data from the powerbi api.  

let
    getgroups_uri ="https://api.powerbi.com/v1.0/myorg/groups",
    GetGroups = Json.Document(Web.Contents(getgroups_uri, 
                [
                Headers=
                    [
                    Authorization="Bearer "&Token
                    ], 
                ManualStatusHandling={400}
                ]
                )),
    value = GetGroups[value],
    #"Converted to Table" = Table.FromList(value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "isReadOnly", "name"}, {"id", "isReadOnly", "name"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Column1", each ([isReadOnly] = false) and ([name] <> "PowerApps & Flow Citizen Developers")),
    #"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{"name", "Workspace"}})
in
    #"Renamed Columns"

 

This also works without any issues on the desktop app. Basically a very simple api call with a token in the header.

The problem becomes when i upload this to powerbi.com

 

I try to refresh and i get:

Data source errorScheduled refresh has been disabled because at least one data source is missing credentials. For refresh to succeed, you must provide credentials for all data sources. Please enter the data source credentials on the dataset settings page and then reactivate scheduled refresh.

 

 

After going into the data source credentials part of the data set, the first web call is still able to connect but the second call to powerbi.com says: Your data source can't be refreshed because the credentials are invalid. Please update your credentials and try again. 

 

It should be an anonymous conenction but it won't let me select that.

Failed to update data source credentials: The credentials provided for the Web source are invalid. (Source at https://api.powerbi.com/v1.0/myorg/groups.)

 

Has anyone had any luck with getting around this? Open to any and alll tips/tricks/suggestions/workarounds/alternatives 

 

1 REPLY 1
v-danhe-msft
Employee
Employee

Hi @sjc4062,

Based on my research, the token of the Power BI API is changed by sometime, I am afraid you could not get a dynamic token to get the data currently, maybe you could submit an idea in ideas forum: https://ideas.powerbi.com/forums/265200-power-bi-ideas

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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