Forum Discussion

Sankzpower's avatar
Sankzpower
Helper I
6 years ago

Restrict API call till it reaches certain value

Hi all

 

Hope someone can help.

The data which I retrive from API call contains three properties such as hasMore, items and errors.
hasMore will be true if there are more items to be returned, items will contain an array of the type of data requests.
Each of them has data inside it for example: hasMore signifies whether the pages contains more data or not so its always
be either True or Fale. Currently, I have a query which pulls in the data by definite page number so currently it set
to page 50 so query runs for page 50. Each pages contains 100 rows hence I had to go through each pages to retrieve all
data. Below is an simple example code which I use to retrieve

 

 

 

let
    Source = Json.Document(Web.Contents("https://cloud.com/api/user?apiKey=c661b7&orderby=name&page=1")),
    #"Converted to Table" = Record.ToTable(Source),
    Value = #"Converted to Table"{0}[Value],
    #"Converted to Table1" = Table.FromList(Value, Splitter.SplitByNothing(), null, null, ExtraValues.Ignore),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table1", "Column1", {"id", "name", "utilityCategoryId", "utilityId", "isARec"}, {"id", "name", "utilityCategoryId", "utilityId", "isARec"})
in
    #"Expanded Column1"

 

 

 

 

 

 

However, I am looking to see if I can use "HasMore" to retrieve data from multiple pages until query hits HasMore FALSE?
Not sure, if its possible - any help would be appreciated?

Thanks