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
My friend, thank you very much for your reply. I understood what you said very well, but now I have other questions. My API supports a range of dates, so I believe I can set StartDateText and EndDateText. However, you say this would eliminate the need for the SQL calendar and the loop function. So are you saying that, with this, I wouldn't need the calendar table in my SQL to ensure query folding? That's the first question.
The second question is: If I don't need the SQL Calendar, where would I "apply" the RangeStart and RangeEnd parameters? Shouldn't I apply them to a date column?
Could you (if possible) demonstrate what my M query would look like where I invoke the function (the one you provided)?