<?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: Passing parameters using PROC HTTP POST method in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420587#M67888</link>
    <description>&lt;P&gt;I am still getting a 400 Bad Request error even after url encoding the IN string.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Dec 2017 21:11:34 GMT</pubDate>
    <dc:creator>KAZ</dc:creator>
    <dc:date>2017-12-12T21:11:34Z</dc:date>
    <item>
      <title>Passing parameters using PROC HTTP POST method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420514#M67881</link>
      <description>&lt;P&gt;I am attempting to retrieve a json response from an API.&amp;nbsp; I am able to get a valid response using curl, but am unable to get PROC HTTP to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The curl statement requires a -d argument: -d '{"cpId": 1}'&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I presume the IN= option in the PROC HTTP statement is the way to go but I receive a Bad Request error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc http webusername="&amp;amp;_user" webpassword="&amp;amp;_pwd"
    url="&amp;amp;_url"
 &amp;nbsp;&amp;nbsp; in='payload={"cpId": 1}'
    method="POST"
    out=_cpr
    headerout=_cprh;
    headers 'Content-Type' = 'application/json';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am running 9.4M4.&amp;nbsp; Any suggestions?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 16:39:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420514#M67881</guid>
      <dc:creator>KAZ</dc:creator>
      <dc:date>2017-12-12T16:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters using PROC HTTP POST method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420569#M67886</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the -d option, I think the server might be expecting the input to be URL encoded, right?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pl = %sysfunc(urlencode(payload={"cpId": 1}));
proc http webusername="&amp;amp;_user" webpassword="&amp;amp;_pwd"
    url="&amp;amp;_url"
    in="&amp;amp;pl."
    method="POST"
    out=_cpr
    headerout=_cprh;
    headers 'Content-Type' = 'application/json';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other stabs in the dark:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You didn't mention whether this was for a mutipart form, but in case it is, you might &lt;A href="https://communities.sas.com/t5/SAS-Procedures/multipart-form-data-REST-API-POST-in-PROC-HTTP-failing/m-p/325284#M62218" target="_self"&gt;get something from this thread&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;And this one about &lt;A href="https://communities.sas.com/t5/SAS-Procedures/SAS-Access-to-REDCap-using-PROC-HTTP/m-p/291293#M59875" target="_self"&gt;REDCap might also be similar&lt;/A&gt;.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 12 Dec 2017 20:27:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420569#M67886</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-12-12T20:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters using PROC HTTP POST method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420587#M67888</link>
      <description>&lt;P&gt;I am still getting a 400 Bad Request error even after url encoding the IN string.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 21:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420587#M67888</guid>
      <dc:creator>KAZ</dc:creator>
      <dc:date>2017-12-12T21:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters using PROC HTTP POST method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420597#M67889</link>
      <description>&lt;P&gt;I just noticed that your curl example does not have the keyword "payload".&amp;nbsp; Is that correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, can you refine the attempt to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pl = %sysfunc(urlencode({"cpId": 1}));
proc http webusername="&amp;amp;_user" webpassword="&amp;amp;_pwd"
    url="&amp;amp;_url"
    in="&amp;amp;pl."
    method="POST"
    out=_cpr
    headerout=_cprh;
    headers 'Content-Type' = 'application/json';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you can share what API you're trying to access (if it's publicly documented), we might be able to find the right approach.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 21:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420597#M67889</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-12-12T21:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters using PROC HTTP POST method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420607#M67890</link>
      <description>&lt;P&gt;I am attempting to hit the OpenSpecimen -&amp;gt; Get Registrations API.&amp;nbsp; The documentation is &lt;A href="https://openspecimen.atlassian.net/wiki/spaces/CAT/pages/14811290/Get+Registrations" target="_self"&gt;here&lt;/A&gt;, but not very helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The working curl code, with just the user and url removed is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;curl -H "Content-Type: application/json" -X POST -d '{"cpId": 1}' &lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Dec 2017 21:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420607#M67890</guid>
      <dc:creator>KAZ</dc:creator>
      <dc:date>2017-12-12T21:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters using PROC HTTP POST method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420612#M67891</link>
      <description>&lt;P&gt;I can't get to that link -- hidden behind an Atlassian login.&amp;nbsp; But have you tried once without the "payload=" and&amp;nbsp;&lt;STRONG&gt;not&lt;/STRONG&gt; a urlendoded version of the IN=?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 21:39:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420612#M67891</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-12-12T21:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters using PROC HTTP POST method</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420613#M67892</link>
      <description>&lt;P&gt;Thank You!&amp;nbsp;&amp;nbsp; For posterity, here is the working code:&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 http webusername="&amp;amp;_user" webpassword="&amp;amp;_pwd"
    url="&amp;amp;_url"
    in='{"cpId": 1}'
    method="POST"
    out=_cpr
    headerout=_cprh;
    headers 'Content-Type' = 'application/json';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 21:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Passing-parameters-using-PROC-HTTP-POST-method/m-p/420613#M67892</guid>
      <dc:creator>KAZ</dc:creator>
      <dc:date>2017-12-12T21:48:02Z</dc:date>
    </item>
  </channel>
</rss>

