Forum Discussion
TrainPerson
3 years agoFrequent Visitor
API loop with List.IsEmpty not working
I am trying to call a REST API with a POST request. There is a limit of 1000 entries per page and it is unclear how many pages there are. I found a sample solution that seems to fit, which is to call...
- 3 years ago
Seems to work fine here
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyaKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]), APIQuery = (n)=> if n<6 then {0..n} else {}, #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", (k)=> List.Generate( () => [offset = 0, List = APIQuery(0) ], each not List.IsEmpty( [List]), each [offset = [offset] + 1, List = APIQuery( [offset] ) ], each [List] )), #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"), #"Expanded Custom1" = Table.ExpandListColumn(#"Expanded Custom", "Custom") in #"Expanded Custom1"
lbendlin
3 years agoSuper User
"List" is a reserved word. Find another name for your variable.