<?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: PROC HTTP error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454437#M283930</link>
    <description>&lt;P&gt;The message indicates that the JSON engine found what it considers an illegal JSON character in the file. Take a look at or post the file returned from running PROC HTTP.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Apr 2018 14:14:18 GMT</pubDate>
    <dc:creator>BillM_SAS</dc:creator>
    <dc:date>2018-04-16T14:14:18Z</dc:date>
    <item>
      <title>PROC HTTP error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/452566#M283927</link>
      <description>&lt;P&gt;I got an error when i run the proc http. I try to get the json file of&amp;nbsp;medicine named "&lt;SPAN&gt;acetaminophen w/codeine #3 tablets&lt;/SPAN&gt;". But there is an error when i run the "&lt;STRONG&gt;libname m JSON fileref=resp2;&lt;/STRONG&gt;". The error is "&lt;STRONG&gt;ERROR: Invalid JSON in input near line 1 column 1: Encountered an illegal character. ERROR: Error in the LIBNAME statement.".&amp;nbsp;&lt;/STRONG&gt;However from the&amp;nbsp;url, i can see there is a valid json file. I do not know why I cannot get it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filename resp2 temp;&lt;BR /&gt;proc http&lt;BR /&gt;url="&lt;A href="https://rxnav.nlm.nih.gov/REST/approximateTerm.json?term=" target="_blank"&gt;https://rxnav.nlm.nih.gov/REST/approximateTerm.json?term=&lt;/A&gt;&lt;STRONG&gt;acetaminophen w/codeine #3 tablets&lt;/STRONG&gt;"&lt;BR /&gt;method= "GET"&lt;BR /&gt;out=resp2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;libname m JSON fileref=resp2;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ERROR: Invalid JSON in input near line 1 column 1: Encountered an illegal character.&lt;BR /&gt;ERROR: Error in the LIBNAME statement.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2018 17:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/452566#M283927</guid>
      <dc:creator>luu</dc:creator>
      <dc:date>2018-04-09T17:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/452569#M283928</link>
      <description>&lt;P&gt;What version of SAS are you using? If you're not sure, you can use the code below and check the log. JSON is in the latest version of SAS (9.4 TS1M5 I think, possibly M4)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc product_status;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Apr 2018 17:22:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/452569#M283928</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-09T17:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/452571#M283929</link>
      <description>&lt;P&gt;I'm using 9.4_m5. I can run through the other medicine but not worked for this one.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2018 17:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/452571#M283929</guid>
      <dc:creator>luu</dc:creator>
      <dc:date>2018-04-09T17:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454437#M283930</link>
      <description>&lt;P&gt;The message indicates that the JSON engine found what it considers an illegal JSON character in the file. Take a look at or post the file returned from running PROC HTTP.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 14:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454437#M283930</guid>
      <dc:creator>BillM_SAS</dc:creator>
      <dc:date>2018-04-16T14:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454485#M283931</link>
      <description>&lt;P&gt;Thank you for you reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, you are right, there is an &lt;SPAN&gt;illegal JSON character in the file. But I don't know how to&amp;nbsp;deal with it.&amp;nbsp;I&amp;nbsp;don't know how to see the file generated by proc http. And i post my code. Could you give me further suggestion of it! Thank you very much!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filename med1 temp;&lt;BR /&gt;proc http&lt;BR /&gt;url="&lt;A href="https://rxnav.nlm.nih.gov/REST/approximateTerm.json?term=acetaminophen" target="_blank"&gt;https://rxnav.nlm.nih.gov/REST/approximateTerm.json?term=acetaminophen&lt;/A&gt; w/codeine #3"&lt;BR /&gt;method= "GET"&lt;BR /&gt;out=med1;&lt;BR /&gt;run;&lt;BR /&gt;libname resp1 JSON fileref=med1;&lt;BR /&gt;data Approximategroup_candidate;&lt;BR /&gt;set resp1.Approximategroup_candidate;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 15:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454485#M283931</guid>
      <dc:creator>luu</dc:creator>
      <dc:date>2018-04-16T15:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454515#M283932</link>
      <description>&lt;P&gt;By specifying TEMP for the file location in the filename statement, the output from running PROC HTTP is sent to a temporary file in the SAS temporary location. You could look at the temporary file by using this macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro fileecho(fn);&lt;BR /&gt;data _NULL_;&lt;BR /&gt;&amp;nbsp; infile &amp;amp;fn length=L;&lt;BR /&gt;&amp;nbsp; input @1 line $varying32767. L;&lt;BR /&gt;&amp;nbsp; put&amp;nbsp;&amp;nbsp; @1 line $varying32767. L;&lt;BR /&gt;&amp;nbsp; run;&lt;BR /&gt;%mend&amp;nbsp; fileecho;&lt;BR /&gt;&lt;BR /&gt;%fileecho(med1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, you could specify a file name in the FILENAME statement to write the HTTP output to a permanent file:&lt;/P&gt;
&lt;P&gt;FILENAME med1 './procHttpOutput.out';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But when I run the code you posted I see the following in the SAS Log window:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: 400 Bad Request&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I then look at the output from the PROC HTTP, I see an error message in XML format:&lt;/P&gt;
&lt;P&gt;&amp;lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&amp;gt;&lt;BR /&gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;title&amp;gt;400 Bad Request&amp;lt;/title&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&amp;lt;h1&amp;gt;Bad Request&amp;lt;/h1&amp;gt;&lt;BR /&gt;&amp;lt;p&amp;gt;Your browser sent a request that this server could not understand.&amp;lt;br /&amp;gt;&lt;BR /&gt;&amp;lt;/p&amp;gt;&lt;BR /&gt;&amp;lt;hr&amp;gt;&lt;BR /&gt;&amp;lt;address&amp;gt;Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_perl/2.0.9 Perl/v5.22.1 S&lt;BR /&gt;erver at mor.nlm.nih.gov Port 443&amp;lt;/address&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;The XML formatted message will definitely result in a illegal character message from the JSON engine. Since this works with other drugs, I suspect that there is a problem with how you are specifying the drug name. Did the drug names that worked include spaces in the drug name specified?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 17:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454515#M283932</guid>
      <dc:creator>BillM_SAS</dc:creator>
      <dc:date>2018-04-16T17:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454517#M283933</link>
      <description>&lt;P&gt;It works by excluding the number sign, "#", from the drug name:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;73&amp;nbsp;&amp;nbsp; proc http&lt;BR /&gt;74&amp;nbsp;&amp;nbsp; url="&lt;A href="https://rxnav.nlm.nih.gov/REST/approximateTerm.json?term=acetaminophen" target="_blank"&gt;https://rxnav.nlm.nih.gov/REST/approximateTerm.json?term=acetaminophen&lt;/A&gt; w/ codeine 3"&lt;BR /&gt;75&amp;nbsp;&amp;nbsp; method= "GET"&lt;BR /&gt;76&amp;nbsp;&amp;nbsp; out=med1;&lt;BR /&gt;77&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&lt;BR /&gt;NOTE: PROCEDURE HTTP used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.31 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;BR /&gt;&lt;BR /&gt;NOTE: 200 OK&lt;BR /&gt;&lt;BR /&gt;78&amp;nbsp;&amp;nbsp; %fileecho(med1);&lt;BR /&gt;&lt;BR /&gt;NOTE: The infile MED1 is:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Filename=C:\Users\sasbim\AppData\Local\Temp\SAS Temporary Files\_TD15416_d10b742_\#LN00010,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RECFM=V,LRECL=32767,File Size (bytes)=576,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Last Modified=16Apr2018:13:39:38,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create Time=16Apr2018:13:18:32&lt;BR /&gt;&lt;BR /&gt;{"approximateGroup":{"inputTerm":"acetaminophen w/ codeine 3","comment":"","candidate":[{"rxcui":"&lt;BR /&gt;817579","rxaui":"3297609","score":"50","rank":"1"},{"rxcui":"817579","rxaui":"798172","score":"50"&lt;BR /&gt;,"rank":"1"},{"rxcui":"817579","rxaui":"798171","score":"50","rank":"1"},{"rxcui":"817579","rxaui"&lt;BR /&gt;:"3095428","score":"50","rank":"1"},{"rxcui":"817579","rxaui":"3095427","score":"50","rank":"1"},{&lt;BR /&gt;"rxcui":"817579","rxaui":"2626344","score":"50","rank":"1"},{"rxcui":"817579","rxaui":"3076140","s&lt;BR /&gt;core":"50","rank":"1"},{"rxcui":"1945644","rxaui":"798175","score":"50","rank":"1"}]}}&lt;BR /&gt;NOTE: 1 record was read from the infile MED1.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The minimum record length was 576.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The maximum record length was 576.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;BR /&gt;79&amp;nbsp;&amp;nbsp; libname resp1 JSON fileref=med1;&lt;BR /&gt;NOTE: JSON data is only read once.&amp;nbsp; To read the JSON again, reassign the JSON LIBNAME.&lt;BR /&gt;NOTE: Libref RESP1 was successfully assigned as follows:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Engine:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JSON&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Physical Name: C:\Users\sasbim\AppData\Local\Temp\SAS Temporary&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Files\_TD15416_d10b742_\#LN00010&lt;BR /&gt;80&amp;nbsp;&amp;nbsp; data Approximategroup_candidate;&lt;BR /&gt;81&amp;nbsp;&amp;nbsp; set resp1.Approximategroup_candidate;&lt;BR /&gt;82&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&lt;BR /&gt;NOTE: There were 8 observations read from the data set RESP1.APPROXIMATEGROUP_CANDIDATE.&lt;BR /&gt;NOTE: The data set WORK.APPROXIMATEGROUP_CANDIDATE has 8 observations and 6 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.03 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 17:44:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454517#M283933</guid>
      <dc:creator>BillM_SAS</dc:creator>
      <dc:date>2018-04-16T17:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454539#M283934</link>
      <description>&lt;P&gt;Thank you very much for your explanation! It is very helpful!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess it is the # char make the error because the other records can run without any problem. But I cannot change the original data. My work is cleaning these messy records to get the matched information from the website.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So is there any way to detect these error and write a if condition statement to avoid&amp;nbsp;running these kinds of records?&lt;/P&gt;&lt;P&gt;I try to use "syserr" to prevent this error but it is not worked. Do you have any suggestion about it? Thanks again!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 18:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454539#M283934</guid>
      <dc:creator>luu</dc:creator>
      <dc:date>2018-04-16T18:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454547#M283935</link>
      <description>&lt;P&gt;There is an example in the documentation:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.3&amp;amp;docsetId=proc&amp;amp;docsetTarget=n1ietrp9bhfq65n1px6nxl6vp9df.htm" target="_self"&gt;HTTP Procedure Documentation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.3&amp;amp;docsetId=proc&amp;amp;docsetTarget=n1ietrp9bhfq65n1px6nxl6vp9df.htm" target="_self"&gt;Example 14: Using the Status Reporting Macro Variables&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 19:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454547#M283935</guid>
      <dc:creator>BillM_SAS</dc:creator>
      <dc:date>2018-04-16T19:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454548#M283936</link>
      <description>&lt;P&gt;Great! I will see these documents and let you know the results! Thanks again for your great help!!!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 19:38:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/454548#M283936</guid>
      <dc:creator>luu</dc:creator>
      <dc:date>2018-04-16T19:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/458270#M283937</link>
      <description>I tried to rewrite the code again, and the SYS_PROCHTTP_STATUS_CODE can solve my problem! Thank you very much!</description>
      <pubDate>Fri, 27 Apr 2018 21:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-HTTP-error/m-p/458270#M283937</guid>
      <dc:creator>luu</dc:creator>
      <dc:date>2018-04-27T21:50:15Z</dc:date>
    </item>
  </channel>
</rss>

