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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mrkglstn
Frequent Visitor

Dynamic data source API Query

Hey everyone

Sorry for reaching out as i have tried so hard to solve this myself.  I have a data source to an API via Json, and it loops through the pages to get the info.  Code is below.


Runs the refresh perfectly on the desktop service but refuses on the web based version.  It says "Dataset includes a dynamic data source" - Done loads of googling and i know its because of the relative hyperlink, but have tried all the combinations out there to get it to work and it just refuses.

Can someone with a massive brain save a man from loosing any more hair! - Please!

 

This is my code

 

let
StartUrl = "https://app.timetastic.co.uk/api/holidays",
Token = "xxxxxxx",

GetJson = (Url) =>
let Options = [Headers=[ #"Authorization" = "Bearer " & Token ]],
RawData = Web.Contents(Url, Options),
Json = Json.Document(RawData),
NextList = Json[holidays],
NextPageUrl = Json[nextPageLink],
Result = if @NextPageUrl = "" then @NextList else @NextList & @GetJson(@NextPageUrl)
in Result,


Output = GetJson(StartUrl),
Table = Table.FromList(Output, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
HolidayDetails = Table.ExpandRecordColumn(Table, "Column1", {"id", "startDate", "startType", "endDate", "endType", "userId", "userName", "requestedById", "leaveTypeId", "duration", "deduction", "actionerId", "createdAt", "updatedAt", "reason", "declineReason", "status", "autoApproved", "bookingUnit", "leaveType"}, {"id", "startDate", "startType", "endDate", "endType", "userId", "userName", "requestedById", "leaveTypeId", "duration", "deduction", "actionerId", "createdAt", "updatedAt", "reason", "declineReason", "status", "autoApproved", "bookingUnit", "leaveType"}),
#"Changed Type" = Table.TransformColumnTypes(HolidayDetails,{{"endDate", type datetime}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"endDate", type date}, {"startDate", type datetime}}),
#"Changed Type2" = Table.TransformColumnTypes(#"Changed Type1",{{"startDate", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type2", "Dates", each List.Dates([startDate],[#"duration"],Duration.From(1))),
#"Expanded Dates" = Table.ExpandListColumn(#"Added Custom", "Dates"),
#"Added Custom1" = Table.AddColumn(#"Expanded Dates", "DayOfWeek", each Date.DayOfWeek([Dates],Day.Monday)),
#"Filtered Rows" = Table.SelectRows(#"Added Custom1", each ([DayOfWeek] <> 5 and [DayOfWeek] <> 6)),
#"Added Custom2" = Table.AddColumn(#"Filtered Rows", "WeekCom", each Date.StartOfWeek([Dates])),
#"Added Conditional Column" = Table.AddColumn(#"Added Custom2", "DaysCalc", each if [deduction] >= 1 then 1 else if [deduction] < 1 then [deduction] else null),
#"Added Custom3" = Table.AddColumn(#"Added Conditional Column", "Hours", each ([DaysCalc])*7),
#"Filtered Rows1" = Table.SelectRows(#"Added Custom3", each true),
#"Grouped Rows" = Table.Group(#"Filtered Rows1", {"userName", "Dates"}, {{"Total Hours", each List.Sum([Hours]), type number}})
in
#"Grouped Rows"

2 REPLIES 2
Anonymous
Not applicable

Hi @mrkglstn ,

 

I couldn't open the URL. You may try to use https://app.timetastic.co.uk as URL and use "api/holidays" as parameter

Or you could take a look at these blogs.

https://blog.crossjoin.co.uk/2016/08/16/using-the-relativepath-and-query-options-with-web-contents-i... 

http://blog.datainspirations.com/2018/02/17/dynamic-web-contents-and-power-bi-refresh-errors/

 

Best Regards,

Jay

Hey @Anonymous  - Thanks for taking the time to reply - I have visited both of those sites along with lots of others and cant for the life of me figure out how to implement it in my call.   😞

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.