Forum Discussion

jp23's avatar
jp23
Frequent Visitor
3 years ago
Solved

Dataflow Working with Start and End Date for API with Custom Function

Hello , looking for some guidance, this would seem to be very simple seem to be overthinking it.

I have a table with some basic team information it, as follows:

 

team_idteam_name
3rockets
4astronauts
5moons
6planets

 

Have created a function that takes the team_id and pass it to an API with a start and end date. Unforutnately, I can't just put in a range such as start=2022-06-01 and end=2023-02-01 as it only will provide the first month of data.

 

(teamid) =>
    let
    Source = Json.Document(Web.Contents("https://api.url.example",
    [RelativePath="/sportsteam/" & Number.ToText(teamid) & "?start=2022-06-01" & "end=2023-02-01",
    Headers=[Authorization="authgoeshere"]]))
in
    Source

 

 

I have tried a few different things but can't seem to get it to work. First, I've created 2 paramaters with lists of values for each year/month combination and pass those as paramaters in the function above. It still will only bring back the first month (i.e. first row in the parameters list). I also tried creating a table with the each month in URL format to pass to the function, but it gives me the same type of response. It's not looping as one would expect.

 

My thought is that I need to create start/end variables like I've done but alter the above code to repeat with the next row of the paramater OR I need to change my table so it has a row for each year/month per team. Any advice is greatly appreciated.