Forum Discussion
how to fully load data from limited HTTP API?
I need to load all data from the API, but the server returns a maximum of 100 rows.
at the link below, if I change the limit=100 to a bigger number, it returns with 100.
to get more data, I need to change offset=0 to another part, for instance offset=100, offset=200 and so on.
https://<testserver>.com/<token>?limit=100&offset=0&date_range=201701010000:201712310000
I did manage to use parameters under WEB load, advanced options, but it loads only one set of 100 rows, and I need to import ALL rows from this link.
the code below works, but does not returns full table, and I need full table.
=Json.Document(Web.Contents("https://<testserver>.com/<token>?limit=100&offset=" & offsettt & "&date_range=201001010000:201912310000"))
in this code, offsettt is the list I made with possible values for offset, but it returns only 100 rows at max.
today, maximum possible offset is around 3000, but everyday this database keeps growing.
how do I loop this loading process, to get all possible rows in one query?
12 Replies
- AnonymousNot applicable
what I need is something similar to this topic:
https://community.powerbi.com/t5/Desktop/how-to-create-a-query-that-paginates/td-p/20047/page/2
but somehow I still could not find a solution for me.
my server API returns this:
offset=actual starting value, if not set it returns 0, to start at row 0;
limit=maximum is 100;next_offset=show the start of the next offset. if I start offset=300, limit=100, but there are only 7 more rows to load, next_offset will be 307. if there are thousands more, next_offset will always be offset+limit, in this example 300+100=400.
from_cache=TRUE if there is more data, FALSE if no more data to show. but I think I can use only the next_offset value in this loading procedure.
- dkay84_PowerBIMicrosoft Employee
See if you can adapt this for your scenario:
https://www.linkedin.com/pulse/loading-data-paged-related-from-ms-graph-api-power-bi-rob-reilly
Otherwise, you will have to create some kind of logic within your query to use the offset+limit only if the count of results is a multiple of 100. That way, if the result count is 307, it will know that there are no more results. Additionally, if there are exactly 300 (or other multiple of 100) results, then offset+limit wont work, so you will have to incorporate some error handling.
- AnonymousNot applicable
hi dkay84.
I read the link twice, tested both scripts in it, but they simply does not work.
A simple copy+paste shows error on the second line: missing Eof "GetUserDetail = (Path)=>".
what does that means?
I am new to M language and I cannot find the error on the script.