<?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 - URL containing quotes in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/589186#M75935</link>
    <description>&lt;P&gt;Can you tell me what service you're trying to use?&amp;nbsp; Sometimes it helps me to reference the doc for the API in answering these.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "data=" is something we see on the cURL examples that are often provided in API doc, but in that case "data" is a keyword for cURL and not part of the API syntax.&amp;nbsp; The body of the request -- passed in that data field -- would belong on the IN= param for PROC HTTP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or...do you have a cURL example that works/should work?&amp;nbsp; If so, we can transcribe to PROC HTTP.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Sep 2019 20:13:45 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2019-09-16T20:13:45Z</dc:date>
    <item>
      <title>PROC HTTP - URL containing quotes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/582227#M75692</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to use PROC HTTP to access an API URL that contains double quotes, as shown:&lt;/P&gt;&lt;P&gt;&lt;A href="https://example.com/api.pro?method=login&amp;amp;data=" target="_blank"&gt;https://example.com/api.pro?method=login&amp;amp;data=&lt;/A&gt;{ "username":"testuser","password": "testpassword" }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This syntax works correctly when pasted directly into a browser.&amp;nbsp; When run in SAS code as below, the call fails.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We're running SAS 9.4 (ts1m3).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;proc http&lt;BR /&gt;url="&lt;A href="https://example.com/api.pro?method=login&amp;amp;data=" target="_blank"&gt;https://example.com/api.pro?method=login&amp;amp;data=&lt;/A&gt;{ "username":"testuser","password": "testpassword" }"&lt;BR /&gt;method = "POST"&lt;BR /&gt;out=resp&lt;BR /&gt;headerout=hdrs;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The response data from the call is:&lt;/P&gt;&lt;P&gt;{"success":false,"error":"Web services not available at this address","errno":10000}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm assuming it has to do with the quotes in the URL...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 19:30:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/582227#M75692</guid>
      <dc:creator>JFinkeldey</dc:creator>
      <dc:date>2019-08-19T19:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - URL containing quotes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/582235#M75693</link>
      <description>&lt;P&gt;Try next assignment:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;url="https://example.com/api.pro?method=login&amp;amp;data={ ""username"":""testuser"",""password"": ""testpassword"" }"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As the url literal is written between double quotes, each inside pair "" will be treated as one ".&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 19:44:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/582235#M75693</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-08-19T19:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - URL containing quotes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/582250#M75694</link>
      <description>&lt;P&gt;Your browser is probably swapping in the encoded characters for the double quotes -- but PROC HTTP won't do that for you.&amp;nbsp; You should probably use the URLENCODE function.&amp;nbsp; &lt;A href="https://blogs.sas.com/content/sasdummy/2018/04/04/htmlencode-urlencode/" target="_self"&gt;See an example here&lt;/A&gt;.&amp;nbsp; I mocked up something here that might do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let values=%sysfunc(urlencode(%str({ "username":"testuser","password": "testpassword" })));
proc http
url="https://example.com/api.pro?method=login%str(&amp;amp;)data=&amp;amp;values."
method = "POST"
out=resp
headerout=hdrs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Aug 2019 20:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/582250#M75694</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2019-08-19T20:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - URL containing quotes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/582421#M75698</link>
      <description>&lt;P&gt;Double quoting causes SAS to interpret the &amp;amp; as a macro variable...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference DATA not resolved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With response of:&lt;/P&gt;&lt;P&gt;{"success":false,"error":"Web services not available at this address","errno":10000}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 13:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/582421#M75698</guid>
      <dc:creator>JFinkeldey</dc:creator>
      <dc:date>2019-08-20T13:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - URL containing quotes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/582423#M75699</link>
      <description>&lt;P&gt;That gives me the same response:&lt;/P&gt;&lt;P&gt;{"success":false,"error":"Web services not available at this address","errno":10000}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The API documentation says that the info needs to be passed in a variable named DATA.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Is it possible to code that as part of an IN= clause?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 13:40:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/582423#M75699</guid>
      <dc:creator>JFinkeldey</dc:creator>
      <dc:date>2019-08-20T13:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - URL containing quotes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/582570#M75700</link>
      <description>&lt;P&gt;Yes - you should try that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename resp temp;
filename hdout temp;
proc http
 url="https://example.com/api.pro?method=login"
 method = "POST"
 in='{ "username":"testuser","password": "testpassword" }'
 out=resp
 headerout=hdrs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Aug 2019 19:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/582570#M75700</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2019-08-20T19:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - URL containing quotes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/589169#M75934</link>
      <description>&lt;P&gt;Chris:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the in= code the API returns the following:&lt;/P&gt;&lt;P&gt;{"success":false,"error":"Unable to locate \"data\" field in REQUEST","errno":0}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That seems like the call can't find the data field, which is expressly identified when putting the entire call on the URL line....&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 19:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/589169#M75934</guid>
      <dc:creator>JFinkeldey</dc:creator>
      <dc:date>2019-09-16T19:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP - URL containing quotes</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/589186#M75935</link>
      <description>&lt;P&gt;Can you tell me what service you're trying to use?&amp;nbsp; Sometimes it helps me to reference the doc for the API in answering these.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "data=" is something we see on the cURL examples that are often provided in API doc, but in that case "data" is a keyword for cURL and not part of the API syntax.&amp;nbsp; The body of the request -- passed in that data field -- would belong on the IN= param for PROC HTTP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or...do you have a cURL example that works/should work?&amp;nbsp; If so, we can transcribe to PROC HTTP.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 20:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-URL-containing-quotes/m-p/589186#M75935</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2019-09-16T20:13:45Z</dc:date>
    </item>
  </channel>
</rss>

