Forum Discussion
Incremental Refresh with API
- Anonymous1 year ago
Hi PedroModa,
Power BI won’t let your report refresh online if your Web.Contents uses a URL that’s built using text joined together while the report is running. That’s because Power BI doesn’t know in advance what websites or addresses it might try to access.
To fix this, you should separate the main part of the URL (the base) from the parts that change (like dates or filters). You can do that by using the Query and RelativePath options in Web.Contents, like below.
(DataInicio as text, DataFim as text) => let Fonte = Json.Document( Web.Contents( "https://api.example.com", // Static base URL [ RelativePath = "endpoint", // Static relative path Query = [ DATAINICIO_D = DataInicio, DATAFINAL_D = DataFim], Headers = [ #"Authorization" = "Bearer YOUR_TOKEN" // Or whatever is required ]])) in Fonte
DataNinja777 , how are you?
I discovered that the previous error was due to the way I constructed my function. Since I separated the relative path from web.contents, my API tried to authenticate but failed. Therefore, it didn't return data when I published to the service. It tried to authenticate only on the web.contents URL, but failed. So, I had to combine the URL with the relative path, and it worked. I have to leave these parameters in order to connect to my API. However, by resolving the problem from the previous error by combining my URL into a single set, my function looks like this:
(DataInicio as text, DataFim as text) =>
let
FullUrl = "MYAPI/RELATIVEPATH/?parameters=DATAINICIO_D=" & DataInicio & ";DATAFINAL_D=" & DataFim,
Fonte = Json.Document(
Web.Contents(FullUrl)
)
in
Fonte
However, now when I publish, this error appears:
This dataset includes a dynamic data source. Since dynamic data sources aren't refreshed in the Power BI service, this dataset won't be refreshed. Learn more: https://aka.ms/dynamic-data-sources. Data source for Query1
Do you know how to help me with this?