<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic List.Generate API Pagination based on rel=&amp;quot;next&amp;quot; in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3880233#M52081</link>
    <description>&lt;P&gt;I am using list.generate to seed the [skip] &amp;amp; [top] values for the URI pagination. I have to guess how many records will be returned, e.g. if I know there are 1000+ records, I set the list.generate condition [skip]&amp;lt; 1100.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the response header no longer returns rel="next" then there are no more records. Where do I include this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my initial code where I manually guess the pagination values. The last step of Table.ExpandListColumns I find the last record [dRofusRecord] = null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
	
    Source = #"200Rooms",
    #"01filterProj" = Table.SelectRows(Source, each ([projName] = projectFilter)),
    #"10listGenerate100" = Table.AddColumn( #"01filterProj", "dRofusRecord", each List.Generate(() =&amp;gt;
    [skip = 0,  top = 10 ],
        each [skip] &amp;lt;= rmSkip,   // rmsSkip is my guess of the record number.
        each [skip = [skip] + [top], 
      top = [top] ]
)),
    #"11expandList" = Table.ExpandListColumn(#"10listGenerate100", "dRofusRecord"),
    #"12expandDrofusRecord" = Table.ExpandRecordColumn(#"11expandList", "dRofusRecord", {"skip", "top"}, {"skip", "top"}),
    #"13changeType" = Table.TransformColumnTypes(#"12expandDrofusRecord",{{"skip", Int64.Type}, {"top", Int64.Type}}),
    
    // API call
    #"20getProjURI" = Table.AddColumn(#"13changeType", "drofusRecord", each getProjectURIpaginated([top], [skip])),

    #"21expandProjURI" = Table.ExpandListColumn(#"20getProjURI", "drofusRecord")
in
    #"21expandProjURI"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the getProjectURIpaginated()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(topVal as number, skipVal as number)=&amp;gt;
let
    #"FilterColumnTable" = Table.SelectRows(#"111APIitemsA1", each ([ObjectType] = "items")),
    GetWebContents =
        Web.Contents(
            "https://api-us.drofus.com/api/company/",
            [
                RelativePath= "143"
                &amp;amp; "/items" 
                &amp;amp; "?$select=" &amp;amp; Text.Combine(#"FilterColumnTable"[dRofus.ID], ",")
                &amp;amp; "&amp;amp;$top=" &amp;amp; Number.ToText(topVal)
                &amp;amp; "&amp;amp;$skip=" &amp;amp; Number.ToText(skipVal) 
            ]
        ),            
    GetBody = Json.Document(GetWebContents)    
in
    GetBody&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have seen videos where I incorporate getProjectURIpaginated() into the list.generate function, but get confused.&lt;/P&gt;&lt;P&gt;Thank you for any help.&lt;/P&gt;</description>
    <pubDate>Fri, 03 May 2024 17:01:09 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-05-03T17:01:09Z</dc:date>
    <item>
      <title>List.Generate API Pagination based on rel="next"</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3880233#M52081</link>
      <description>&lt;P&gt;I am using list.generate to seed the [skip] &amp;amp; [top] values for the URI pagination. I have to guess how many records will be returned, e.g. if I know there are 1000+ records, I set the list.generate condition [skip]&amp;lt; 1100.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the response header no longer returns rel="next" then there are no more records. Where do I include this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my initial code where I manually guess the pagination values. The last step of Table.ExpandListColumns I find the last record [dRofusRecord] = null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
	
    Source = #"200Rooms",
    #"01filterProj" = Table.SelectRows(Source, each ([projName] = projectFilter)),
    #"10listGenerate100" = Table.AddColumn( #"01filterProj", "dRofusRecord", each List.Generate(() =&amp;gt;
    [skip = 0,  top = 10 ],
        each [skip] &amp;lt;= rmSkip,   // rmsSkip is my guess of the record number.
        each [skip = [skip] + [top], 
      top = [top] ]
)),
    #"11expandList" = Table.ExpandListColumn(#"10listGenerate100", "dRofusRecord"),
    #"12expandDrofusRecord" = Table.ExpandRecordColumn(#"11expandList", "dRofusRecord", {"skip", "top"}, {"skip", "top"}),
    #"13changeType" = Table.TransformColumnTypes(#"12expandDrofusRecord",{{"skip", Int64.Type}, {"top", Int64.Type}}),
    
    // API call
    #"20getProjURI" = Table.AddColumn(#"13changeType", "drofusRecord", each getProjectURIpaginated([top], [skip])),

    #"21expandProjURI" = Table.ExpandListColumn(#"20getProjURI", "drofusRecord")
in
    #"21expandProjURI"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the getProjectURIpaginated()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(topVal as number, skipVal as number)=&amp;gt;
let
    #"FilterColumnTable" = Table.SelectRows(#"111APIitemsA1", each ([ObjectType] = "items")),
    GetWebContents =
        Web.Contents(
            "https://api-us.drofus.com/api/company/",
            [
                RelativePath= "143"
                &amp;amp; "/items" 
                &amp;amp; "?$select=" &amp;amp; Text.Combine(#"FilterColumnTable"[dRofus.ID], ",")
                &amp;amp; "&amp;amp;$top=" &amp;amp; Number.ToText(topVal)
                &amp;amp; "&amp;amp;$skip=" &amp;amp; Number.ToText(skipVal) 
            ]
        ),            
    GetBody = Json.Document(GetWebContents)    
in
    GetBody&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have seen videos where I incorporate getProjectURIpaginated() into the list.generate function, but get confused.&lt;/P&gt;&lt;P&gt;Thank you for any help.&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 17:01:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3880233#M52081</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-03T17:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: List.Generate API Pagination based on rel="next"</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3881006#M52090</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please make a littile adjustment as below on your codes and check if it can return your expected result...&lt;/P&gt;
&lt;P&gt;1. Make modification on List.Generate() part&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = #"200Rooms",
    #"01filterProj" = Table.SelectRows(Source, each ([projName] = projectFilter)),
    #"10listGenerate" = Table.AddColumn(#"01filterProj", "dRofusRecord", each List.Generate(
        () =&amp;gt; [skip = 0, top = 10],
        each [skip] &amp;lt;= rmSkip and GetHeaders([top], [skip]),
        each [skip = [skip] + [top], top = [top]]
    )),
    #"11expandList" = Table.ExpandListColumn(#"10listGenerate", "dRofusRecord"),
    #"12expandDrofusRecord" = Table.ExpandRecordColumn(#"11expandList", "dRofusRecord", {"skip", "top"}, {"skip", "top"}),
    #"13changeType" = Table.TransformColumnTypes(#"12expandDrofusRecord",{{"skip", Int64.Type}, {"top", Int64.Type}}),
    #"20getProjURI" = Table.AddColumn(#"13changeType", "drofusRecord", each getProjectURIpaginated([top], [skip])),
    #"21expandProjURI" = Table.ExpandListColumn(#"20getProjURI", "drofusRecord")
in
    #"21expandProjURI"&lt;/LI-CODE&gt;
&lt;P&gt;2. Change the code for the function&amp;nbsp;&lt;SPAN&gt;getProjectURIpaginated()&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;  GetHeaders = (topVal as number, skipVal as number) =&amp;gt;
        let
            #"FilterColumnTable" = Table.SelectRows(#"111APIitemsA1", each ([ObjectType] = "items")),
            GetWebContents =
                Web.Contents(
                      "https://api-us.drofus.com/api/amazon/",
                    [
                        RelativePath= "143"
                        &amp;amp; "/items" 
                        &amp;amp; "?$select=" &amp;amp; Text.Combine(#"FilterColumnTable"[dRofus.ID], ",")
                        &amp;amp; "&amp;amp;$top=" &amp;amp; Number.ToText(topVal)
                        &amp;amp; "&amp;amp;$skip=" &amp;amp; Number.ToText(skipVal) 
                    ]
                ),
            GetHeaders = Record.FieldOrDefault(GetWebContents, "Headers", []),
            LinkHeader = Record.FieldOrDefault(GetHeaders, "Link", ""),
            RelNext = Text.Contains(LinkHeader, "rel=next")
        in
            RelNext&lt;/LI-CODE&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 02:19:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3881006#M52090</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-01T02:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: List.Generate API Pagination based on rel="next"</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3882838#M52097</link>
      <description>&lt;P&gt;Thank you Anonymous&lt;/LI-USER&gt; , I will give this a try.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 13:52:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3882838#M52097</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-01T13:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: List.Generate API Pagination based on rel="next"</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3883149#M52102</link>
      <description>&lt;P&gt;Thank you for the code for GetHeaders(). When I invoke this function, it returns a cannot convert binary to type record. I think this error is between GetWebContents (returns a JSON file) and GetHeaders (returns Binary error).&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I can bypass this error by converting the JSON, which returns a list of records. The GetHeaders is expecting a different input. revised GetHeaders()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(topVal as number, skipVal as number)=&amp;gt;
let
    #"FilterColumnTable" = Table.SelectRows(#"102APImapRooms100", each ([ObjectType] = "rooms")),
    GetWebContents =
        Web.Contents("https://api-us.drofus.com/api/amazon/",
            [
                RelativePath= "01" &amp;amp; "/rooms" 
                &amp;amp; "?$select=" &amp;amp; Text.Combine(#"FilterColumnTable"[dRofus.ID], ",")
                &amp;amp; "&amp;amp;$top=" &amp;amp; Number.ToText(topVal) &amp;amp; "&amp;amp;$skip=" &amp;amp; Number.ToText(skipVal) 
            ]
        ),
    convertedJson = Json.Document(GetWebContents,65001),
    convertedList = Table.FromList(convertedJson, Splitter.SplitByNothing(), null, null, ExtraValues.Error), 
 convertedRecord = Record.FromTable(convertedList),  
     GetHeaders = Record.FieldOrDefault(convertedRecord, "Headers", []),
            LinkHeader = Record.FieldOrDefault(GetHeaders, "Link", ""),
            RelNext = Text.Contains(LinkHeader, "next")
    
        in
            GetHeaders&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;error message at convertedRecord step.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;If I skip this step GetHeaders error: cannot convert value of type Table to type Record.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 20:01:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3883149#M52102</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-01T20:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: List.Generate API Pagination based on rel="next"</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3883158#M52103</link>
      <description>&lt;P&gt;GetHeaders() without the GetHeaders script. Results of GetWebContent.&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 16:04:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3883158#M52103</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-01T16:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: List.Generate API Pagination based on rel="next"</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3889810#M52159</link>
      <description>&lt;P&gt;Thank you Anonymous&lt;/LI-USER&gt;&amp;nbsp; for your help! I decided to take a U-Turn and rethink the solution how to end the API pagination automatically. Fortunately, I found a &lt;A href="https://community.fabric.microsoft.com/t5/Developer/API-loop-with-List-IsEmpty-not-working/m-p/3230891" target="_self"&gt;post&lt;/A&gt; by &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt; using List.IsEmpty().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I revised the List.Generate() section to include the List.Empty().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;= Table.AddColumn(#"01filterProject", "dRofusRecord", each List.Generate(() =&amp;gt;
[projNo = [projNo], skip = 0,  top = 50, recordList = getURI(projNo, top, skip)],

each not List.IsEmpty([recordList]),
each [projNo = [projNo],
      skip = [skip] + [top], 
      top = [top],
       recordList = getURI(projNo, top, skip)]
))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;getURI()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(projNo as text, topVal as number, skipVal as number)=&amp;gt;
let
    #"FilterColumnTable" = Table.SelectRows(#"102APImapRooms100", each ([ObjectType] = "rooms")),
    GetWebContents =
        Web.Contents(
            "https://api-us.drofus.com/api/company/",
            [
                RelativePath= projNo
                &amp;amp; "/rooms" 
                &amp;amp; "?$select=" &amp;amp; Text.Combine(#"FilterColumnTable"[dRofus.ID], ",")
                &amp;amp; "&amp;amp;$top=" &amp;amp; Number.ToText(topVal)
                &amp;amp; "&amp;amp;$skip=" &amp;amp; Number.ToText(skipVal) 
            ]
        ),
    convertedJson = Json.Document(GetWebContents,65001),     
        in
            convertedJson&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 17:35:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3889810#M52159</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-03T17:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: List.Generate API Pagination based on rel="next"</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3893278#M52177</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I’m delighted to hear that your issue has been resolved. Thank you for sharing the solution with our community. Your contribution could prove invaluable to other users who might encounter the same problem. Your efforts are greatly appreciated!&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 01:26:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/List-Generate-API-Pagination-based-on-rel-quot-next-quot/m-p/3893278#M52177</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-06T01:26:41Z</dc:date>
    </item>
  </channel>
</rss>

