<?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: Unexpected end of JSON input in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unexpected-end-of-JSON-input/m-p/892712#M352605</link>
    <description>&lt;P&gt;Because this works OK without the page parameter, I'd suspect the API. Perhaps it isn't properly terminating the JSON object for each page when paginating the results.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Sep 2023 12:12:01 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2023-09-05T12:12:01Z</dc:date>
    <item>
      <title>Unexpected end of JSON input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unexpected-end-of-JSON-input/m-p/892682#M352591</link>
      <description>&lt;P&gt;Hello everyone, I would like to ask some questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I usually use SAS Studio to call data from API. That API made by my colleague has a 10 thousand maximum data to reduce chance of connection loss because of the big number. But sometimes, the data inside is more than 10 thousand, so they made paging for every 10 thousand data. The API would look like this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://website.com/admin/api/v1/survey?surveyID=111111&amp;amp;type=long&amp;amp;page=1" target="_blank"&gt;https://site.com/admin/api/v1/survey?ID=111111&amp;amp;type=long&amp;amp;page=1&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I don't use the page parameter, it would works just fine. But when I use the page parameter when the data is over 10 thousand, this error show up.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="SyntaxError: Unexpected end of JSON input" style="width: 436px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/87612iFFC90321E27344AD/image-size/large?v=v2&amp;amp;px=999" role="button" title="error.jpg" alt="SyntaxError: Unexpected end of JSON input" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;SyntaxError: Unexpected end of JSON input&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The code that I used to call the data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME request HTTP
'https://site.com/admin/api/v1/survey?surveyID=111111&amp;amp;type=long&amp;amp;page=1'
user='user@user.com' password='user123' debug;
DATA NULL;
INFILE request;
INPUT;
PUT INFILE;
RUN;
libname test1 JSON fileref=request;

data work.data_testing;
	set test1.root;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At first, I thought the error would be in the API links. But when I check one by one for every page, it open just fine.&lt;/P&gt;
&lt;P&gt;Is there any solution for this? Or is this error caused by API side?&lt;BR /&gt;&lt;BR /&gt;Thanks.&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;</description>
      <pubDate>Tue, 05 Sep 2023 08:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unexpected-end-of-JSON-input/m-p/892682#M352591</guid>
      <dc:creator>adilar39</dc:creator>
      <dc:date>2023-09-05T08:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected end of JSON input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unexpected-end-of-JSON-input/m-p/892712#M352605</link>
      <description>&lt;P&gt;Because this works OK without the page parameter, I'd suspect the API. Perhaps it isn't properly terminating the JSON object for each page when paginating the results.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 12:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unexpected-end-of-JSON-input/m-p/892712#M352605</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2023-09-05T12:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected end of JSON input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unexpected-end-of-JSON-input/m-p/892714#M352606</link>
      <description>&lt;P&gt;Maybe not helping with the current issue, but if you have issues with data transfer size, timeouts etc, you may should look into other solutions such as file transfer, queuing/messaging (e.g. Kafka).&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 12:22:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unexpected-end-of-JSON-input/m-p/892714#M352606</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2023-09-05T12:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected end of JSON input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unexpected-end-of-JSON-input/m-p/892888#M352688</link>
      <description>I've tried some trial and error and found out that when I call only 2 pages with 20 thousand rows data, it works. But when I add another page, that error would show up.</description>
      <pubDate>Wed, 06 Sep 2023 10:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unexpected-end-of-JSON-input/m-p/892888#M352688</guid>
      <dc:creator>adilar39</dc:creator>
      <dc:date>2023-09-06T10:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected end of JSON input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unexpected-end-of-JSON-input/m-p/893038#M352765</link>
      <description>&lt;P&gt;This error almost always indicates malformed JSON or a response that is NOT JSON at all (like a 404 HTML response page). So I have questions:&lt;/P&gt;
&lt;P&gt;1. When does the error you specified occur?&lt;/P&gt;
&lt;P&gt;2. Is the error generated by SAS? If so, is it from the PROC HTTP step, the LIBNAME statement, or the DATA step?&lt;/P&gt;
&lt;P&gt;3. Have you looked at the raw JSON file to see if you can identify the problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 19:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unexpected-end-of-JSON-input/m-p/893038#M352765</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2023-09-06T19:33:56Z</dc:date>
    </item>
  </channel>
</rss>

