Can you connect an API to Power BI?
Yes! You can connect to (most) API's! Okay, how can we accomplish this?
Choose Get Source
Enter the URI
Use the relative path options argument for more advanced capabilities
1. Choose Get Source
The first step is to choose a data source. Similar to connecting to any other source like a CSV or Excel file.
2. Choose Web
Now, you will just select "Web".
3. Enter the URI
This will usually contain an access token and any filter arguments that the API takes.
4. Use the relative path for more advanced capabilities
“You can’t schedule refresh for this dataset because one or more sources currently don’t support refresh.”
If you want to set up a refresh schedule in service, you'll need to make some modifications in Power Query.
Open up Power Query, navigate to the query that makes the API call. Now, open the Advanced Editor.
In the Web.Contents function, we need to use the options argument and give it a relative path.
webContents = Web.Contents(
"fred/series/observations?series_id=GDP&api_key=" & api_key
Because a relative path is technically a dynamic data source, Power BI requires us to define this in the relative path argument if we want to refresh in the service.
Still won't refresh? Try this other option:
Open your dashboard on desktop
File -> Options -> Privacy
Choose "Always combine"
Still still won't refresh? Try this other option:
In desktop, change privacy settings for the data source to 'Organizational'
Navigate to 'Schedule Refresh' in the service
Expand Data source credentials
Click 'Edit credentials' for the API source.
Change the privacy level to to 'Organizational'
Still still still won't refresh? Try this other option:
"Your data source can't be refreshed because the credentials are invalid. Please update your credentials and try again."
You can try using a gateway and choose 'Skip Test Connection' as described in this post: https://community.powerbi.com/t5/Service/Refreshing-data-from-REST-API-works-on-Desktop-fails-on-Service/td-p/779926
To set up a gateway involves a number of steps outside the scope of this article, but you can read how to do that here: https://learn.microsoft.com/en-us/power-bi/connect-data/service-gateway-data-sources
Still still still still won't refresh?! Try this other option:
"This dataset contains a dynamic data source. Since dynamic data sources aren't refreshed in the Power BI service, this data source won't be refreshed."
Unfortunately you may be out of luck if you have this error. You'll need to rebuild your query so that Power Query is not using the dynamic data source, if at all possible.
Dynamic data sources are strings generated within the M code like database names, CSV file paths, or web URLs.
The only exception to this rule is to use the 'RelativePath' function described above in this article.
Read more about dynamic data sources here: https://learn.microsoft.com/en-us/power-bi/connect-data/refresh-data