<?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 Invalid JSON in Input Error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/478782#M123490</link>
    <description>&lt;P&gt;All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Wondering what this error is trying to prompt me towards and how may I fix it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Objective : Macro making API call and should receive ZIP file in response&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Errors from Log:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;DIV class="sasError"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ERROR: Invalid JSON in input near line 1 column 1: Encountered an illegal character.&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ERROR: Error in the LIBNAME statement.&lt;/EM&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;EM&gt;ERROR: Libref IN is not assigned.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/EM&gt;SAS CODE&lt;EM&gt;:&amp;nbsp;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="sasLog"&gt;&lt;BR /&gt; filename ProjResp "&amp;lt;MyFileName.zip&amp;gt;"; &lt;BR /&gt; libname in json "&amp;lt;MyFileName.zip&amp;gt;";&lt;BR /&gt; &lt;BR /&gt; PROC HTTP &lt;BR /&gt;    URL = &amp;amp;URLDes. &lt;BR /&gt;    Method = "get"&lt;BR /&gt;    out = ProjResp; &lt;BR /&gt;    headers "Authorization" = "Bearer &amp;amp;AccessToken.";&lt;BR /&gt; Run; &lt;BR /&gt; &lt;BR /&gt; Proc Contents Data = in._all_; &lt;BR /&gt; Run; &lt;BR /&gt; %Mend;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jul 2018 19:22:25 GMT</pubDate>
    <dc:creator>UdayGuntupalli</dc:creator>
    <dc:date>2018-07-17T19:22:25Z</dc:date>
    <item>
      <title>Invalid JSON in Input Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/478782#M123490</link>
      <description>&lt;P&gt;All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Wondering what this error is trying to prompt me towards and how may I fix it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Objective : Macro making API call and should receive ZIP file in response&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Errors from Log:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;DIV class="sasError"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ERROR: Invalid JSON in input near line 1 column 1: Encountered an illegal character.&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ERROR: Error in the LIBNAME statement.&lt;/EM&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;EM&gt;ERROR: Libref IN is not assigned.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/EM&gt;SAS CODE&lt;EM&gt;:&amp;nbsp;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="sasLog"&gt;&lt;BR /&gt; filename ProjResp "&amp;lt;MyFileName.zip&amp;gt;"; &lt;BR /&gt; libname in json "&amp;lt;MyFileName.zip&amp;gt;";&lt;BR /&gt; &lt;BR /&gt; PROC HTTP &lt;BR /&gt;    URL = &amp;amp;URLDes. &lt;BR /&gt;    Method = "get"&lt;BR /&gt;    out = ProjResp; &lt;BR /&gt;    headers "Authorization" = "Bearer &amp;amp;AccessToken.";&lt;BR /&gt; Run; &lt;BR /&gt; &lt;BR /&gt; Proc Contents Data = in._all_; &lt;BR /&gt; Run; &lt;BR /&gt; %Mend;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 19:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/478782#M123490</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2018-07-17T19:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid JSON in Input Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/478793#M123493</link>
      <description>&lt;P&gt;Can you direct a JSON library to a ZIP file? I would think it would need to be pointed at the JSON file directly not the ZIP version. There is a ZIP connection as well to access to the text files directly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; libname in json "&amp;lt;MyFileName.zip&amp;gt;";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jul 2018 19:38:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/478793#M123493</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-17T19:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid JSON in Input Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/478798#M123494</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Would you recommend re-directing it to a txt file ? If yes, can you kindly point me to an example on how to identify/parse the different files that are captured in the response ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename ProjResp "&amp;lt;MyFileName.txt&amp;gt;"; 
libname in json "&amp;lt;MyFileName.txt&amp;gt;"; 

  	PROC HTTP 
  		URL = &amp;amp;URLDes. 
  		Method = "get"
  		out = ProjResp; 
  		headers "Authorization" = "Bearer &amp;amp;AccessToken.";
  	Run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I updated my script as shown above. However, the text file is not readable and am wondering if the normal json parse as follows will be sufficient ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; 
      set in.root; 
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; Because, I am not sure, how I can separate the different files expected as part of the output. Can you offer a little more guidance or point me to an example. Would appreciate it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 19:49:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/478798#M123494</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2018-07-17T19:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid JSON in Input Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/478800#M123495</link>
      <description>I don't know what you're trying to do though, you just posted some code, didn't actually explain and there's nothing I can run to test things. For JSON I would suggest google Chris Hemidenger and seeing what his blog posts cover. This isn't a file type I work with often enough and I only installed 9.4 TS1M5 recently which has the JSON support.</description>
      <pubDate>Tue, 17 Jul 2018 19:51:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/478800#M123495</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-17T19:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid JSON in Input Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/478805#M123499</link>
      <description>Sorry, I do see you're hitting an API and returning a ZIP file. That's problematic tbh, a good API should return XML or JSON IMO. Anyways, I do have some code that does this, but it's at home so I'll post it later. If someone else hasn't answered it. But in general you'll need to get the zip file, save it and then process it, which is a bit of a process that you need to define. For example where are you planning to store the files and do you leave them there or delete somehow?</description>
      <pubDate>Tue, 17 Jul 2018 19:59:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/478805#M123499</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-17T19:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid JSON in Input Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/479117#M123618</link>
      <description>&lt;P&gt;Here's the code I was using, it doesn't work anymore because I think they've changed their naming conventions but the idea is the same I think. This was designed to download a ZIP file from Statistics Canada, store&amp;nbsp;it into the work folder and then read it in. This also assumed that I knew the name of the file inside the ZIP file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let CANSIM=02820087;
/* create a name for our downloaded ZIP */
%let ziploc = %sysfunc(getoption(work))/&amp;amp;cansim.-eng.zip;
filename download "&amp;amp;ziploc";
 
/* Download the ZIP file from the Internet*/
proc http
 method='GET'
 url="http://www20.statcan.gc.ca/tables-tableaux/cansim/csv/&amp;amp;cansim.-eng.zip"
 out=download;
run;

filename inzip zip "&amp;amp;ziploc";
filename xl "%sysfunc(getoption(work))/&amp;amp;cansim.-eng-csv";

data _null_;
   /* using member syntax here */
   infile inzip(&amp;amp;cansim.-eng.csv) 
       lrecl=256 recfm=F length=length eof=eof unbuf;
   file   xl lrecl=256 recfm=N;
   input;
   put _infile_ $varying256. length;
   return;
 eof:
   stop;
run;
 
proc import datafile=xl dbms=csv out=confirmed replace;guessingrows=1000000;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Jul 2018 16:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-JSON-in-Input-Error/m-p/479117#M123618</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-18T16:00:45Z</dc:date>
    </item>
  </channel>
</rss>

