Forum Discussion

dusdau's avatar
dusdau
Helper II
6 years ago
Solved

Looping thru a table to perform a REST API call with paging

Hi All,   I've been working on this one a while, and have found many good posts and videos to help but I can't quite get this to the finish line so hoping you can help.   I have a query called 'P...
  • lbendlin's avatar
    6 years ago

    General approach is to use Table.AddColumn on your PhishingTests table where you call the fnGetTestResults and get the contents back into the new table cell (as a table in a table). Then you can decide if you just want to combine the values in that column, or do other fancy stuff with it.

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyVNJRMlWK1QGxjYFsCwjb2ATINoOwTUBqjJViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [pst_id = _t, total_pages = _t]),
        #"Added Custom" = Table.AddColumn(Source, "Content", each fnGetTestResults([pst_id],[total_pages],1))
    in
        #"Added Custom"

     

    Are you sure your API calls return JSON pages that an be converted into tables without issue?

  • dusdau's avatar
    dusdau
    6 years ago

    Thanks lbendlin! What you gave me is what I needed to focus on.  Here is what I finally got working:

     

    Add Column -> Invoke Custom Function

     

    Function 1

     

    Function 2

     

    Seems to work great!  Thanks again!  Hope this helps someone else...