Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 28 -August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more
Hi guys, I am using the below power query code for getting the data from an API. I am using a loop to get the data for many rows as the API can provide onpy 5000 rows for a call. But I am not able to apply data refresh. I even tried using Relative path as suggested by few people, but it's still not working. I cannot provide the API key as it is confidential. Also, keep in mind that I do not want to use personal gateway. Thank you in advance.
let
#"FullQuery" = let
pageSize = 5000,
sendRequest = (page) =>
let
APIKey = "test",
APIUrl = "https://api.genscape.com/",
startDate = Date.ToText(Date.AddMonths(Date.From(DateTimeZone.UtcNow()),-11),"yyyy-MM-dd"),
Response = Web.Contents(
"https://api.genscape.com/",
[
RelativePath ="storage/oil/v1/tank-volumes",
Query=
[
revision="published",
format="json",
startDate=startDate,
limit = Number.ToText(pageSize),
offset = Number.ToText(page * pageSize)
],
Headers=[#"Gen-Api-Key"= APIKey]
]),
Data = Json.Document(Response)[data]
in
Data,
Loop = (page as number, AccumData as list) =>
let
Data = Function.InvokeAfter(()=>sendRequest(page), #duration(0,0,0,2)),
Result =
if List.Count(Data) < pageSize
then Table.FromRecords(List.Combine({AccumData, Data}))
else @Loop(page + 1, List.Combine({AccumData, Data}))
in
Result
in
Loop(0, {})
in
#"FullQuery"
I am getting the below error when I try to schedule refresh.
Solved! Go to Solution.
Sorry I hadn't read your post correctly. What you need is a base URL that actually exists on the service.
https://api.genscape.com/ is not valid (the server refuses to serve that page).
Select "skip test" and ignore the error.
"But I am not able to apply data refresh"
Please elaborate. What error message did you get?
Hi lbendlin,
I am getting the below error message.
Thank you,
Yash
Sorry I hadn't read your post correctly. What you need is a base URL that actually exists on the service.
https://api.genscape.com/ is not valid (the server refuses to serve that page).
Select "skip test" and ignore the error.
Can you successfully fetch a single page? The first ten records? The error message indicates that the URL is incorrect.
Yes, I can fetch a single page when I use the below way to load data instead of using query to load many pages using loop.
Hi @Yash48 ,
Try the measure provided by Chris to deal with 404 error from Web.Contents:
Best Regards,
Kelly
Did I answer your question? Mark my reply as a solution!
Hi Kelly,
That article was not able to solve my problem. The api url is working fine when I use in PowerBI desktop, but not when published.
Thank you,
Yash
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!
Check out the July 2026 Power BI update to learn about new features.