<?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 Re: Paging through rest api results? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Paging-through-rest-api-results/m-p/546396#M151291</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the .net code basically fetches the initial json from the url ( which only returns 1000 rows ), then the last row in the json has a link to the next 1000 rows like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;......"}],"nextLink":"https://sameurl/nextpage?sessiontoken.......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it then runs another get request with the url from nextLink, and repeats until no more nextLink in the data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;does that help with the explanation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 27 Mar 2019 07:48:28 GMT</pubDate>
    <dc:creator>Dwayne-Dibbley</dc:creator>
    <dc:date>2019-03-27T07:48:28Z</dc:date>
    <item>
      <title>Paging through rest api results?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paging-through-rest-api-results/m-p/546229#M151211</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the following code to pull a json file from a url :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options NOQUOTELENMAX;

filename usage "/folders/myfolders/sasuser.v94/usage.json";

%let AccessKey = reallylongstring;
	
proc http
 url="https://a.url"
 method="GET" out=usage;
 headers 
   "Authorization"="Bearer &amp;amp;AccessKey.";
run;

libname usage json "/folders/myfolders/sasuser.v94/usage.json";

data usage;
 set usage.data;
run;

proc print data=usage noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;however now the results are returning more that 1000 results and i need to check for nextLink property somehow?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in .net you could use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;$usagerest = Invoke-Restmethod -url $usageurl -header $authheaders -method get

while ($null -ne $usageRest.nextLink) {
$usageRest = Invoke-Restmethod -uri $usagerest.nextlink -headers $authheaders -method get
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;is something like this possible with proc http in sas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 16:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paging-through-rest-api-results/m-p/546229#M151211</guid>
      <dc:creator>Dwayne-Dibbley</dc:creator>
      <dc:date>2019-03-26T16:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Paging through rest api results?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paging-through-rest-api-results/m-p/546366#M151275</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not too sure what your .Net code does, but you can post-process the data any way you want in the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would that help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 03:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paging-through-rest-api-results/m-p/546366#M151275</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-03-27T03:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Paging through rest api results?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paging-through-rest-api-results/m-p/546396#M151291</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the .net code basically fetches the initial json from the url ( which only returns 1000 rows ), then the last row in the json has a link to the next 1000 rows like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;......"}],"nextLink":"https://sameurl/nextpage?sessiontoken.......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it then runs another get request with the url from nextLink, and repeats until no more nextLink in the data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;does that help with the explanation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 07:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paging-through-rest-api-results/m-p/546396#M151291</guid>
      <dc:creator>Dwayne-Dibbley</dc:creator>
      <dc:date>2019-03-27T07:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Paging through rest api results?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Paging-through-rest-api-results/m-p/547078#M151549</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; it then runs another get request with the url from nextLink, and repeats until no more nextLink in the data&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case I would probably try to read the file as a simple text file using INFILE with the URL engine and FILEVAR= .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then update the next file to read using the FILEVAR= option and start over.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The tricky bit may be to identify the *last*&amp;nbsp;&lt;SPAN&gt;nextLink call, depending on how the JSON file is built.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 01:44:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Paging-through-rest-api-results/m-p/547078#M151549</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-03-29T01:44:14Z</dc:date>
    </item>
  </channel>
</rss>

