<?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: How to make a PROC HTTP Post request by passing a JSON message in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/477268#M122892</link>
    <description>&lt;P&gt;For anyone who come down this path, you will find a solution here (&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/datalines-and-macro-variable/m-p/474033/highlight/true#M121738)&amp;nbsp;" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/datalines-and-macro-variable/m-p/474033/highlight/true#M121738)&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Jul 2018 22:50:40 GMT</pubDate>
    <dc:creator>UdayGuntupalli</dc:creator>
    <dc:date>2018-07-11T22:50:40Z</dc:date>
    <item>
      <title>How to make a PROC HTTP Post request by passing a JSON message</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/476946#M122769</link>
      <description>&lt;P&gt;All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Looking for an example or help on how to make a PROC HTTP request by passing a JSON message. The R code that I put together which works is below :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;RawResponse3 &amp;lt;-POST(RequestURL,
		    add_headers('Authorization' = paste0('Bearer ',AccessToken)),
		    add_headers('Content-Type' = 'application/json;charset=UTF-8'),
		    body = BodyMsg, 
		    encode ='json'
		   )&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; I am thinking the equivalent in SAS would be something like:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc HTTP; 
  	    URL =  "&amp;amp;URLDes."
            Method = "post"
            ct = "application/x-www-form-urlencoded";
            headers "Authorization" = "Bearer &amp;amp;AccessToken.";
  	    encode = 'json';  * Not sure of this line; 
Run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Now, how do I pass the JSON message which is represented by "BodyMsg" in my R code ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 21:33:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/476946#M122769</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2018-07-10T21:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a PROC HTTP Post request by passing a JSON message</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/476986#M122778</link>
      <description>&lt;P&gt;&lt;FONT size="2" face="arial,helvetica,sans-serif"&gt;Have you seen&amp;nbsp;&lt;/FONT&gt;&lt;FONT size="2" face="arial,helvetica,sans-serif"&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2018/01/23/check-json-and-http/" target="_self"&gt;How to test PROC HTTP and the JSON library engine&lt;/A&gt; posted by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;?&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2018 06:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/476986#M122778</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-07-11T06:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a PROC HTTP Post request by passing a JSON message</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/477041#M122802</link>
      <description>&lt;P&gt;To POST some JSON content to a web service, you need to place the content in an external file, then reference that file with the IN= argument on PROC HTTP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Put the body of the JSON content in external file */
filename json_in temp;
data _null_;
file json_in;
input;
put _infile_;
datalines;
{ "name":"value" }
run;

/* reference that file as IN= parm in PROC HTTP POST */
filename resp temp;
proc http 
 method="POST"
 url="http://httpbin.org"
 ct="application/json"
 in=json_in
 out=resp; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Jul 2018 11:46:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/477041#M122802</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-07-11T11:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a PROC HTTP Post request by passing a JSON message</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/477262#M122889</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;The solution you have offered works. But it looks like this cannot be used within a macro. Would you have an alternative if this needed to be implemented in a macro ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2018 22:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/477262#M122889</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2018-07-11T22:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a PROC HTTP Post request by passing a JSON message</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/477268#M122892</link>
      <description>&lt;P&gt;For anyone who come down this path, you will find a solution here (&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/datalines-and-macro-variable/m-p/474033/highlight/true#M121738)&amp;nbsp;" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/datalines-and-macro-variable/m-p/474033/highlight/true#M121738)&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2018 22:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/477268#M122892</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2018-07-11T22:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a PROC HTTP Post request by passing a JSON message</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/477421#M122946</link>
      <description>&lt;P&gt;As you discovered, DATALINES (or CARDS or similar) doesn't work inside of a macro.&amp;nbsp; If the JSON data that you're generating requires the dynamic processing of a macro construct, consider using PUT statements or another data-driven approach like CALL EXECUTE.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 12:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/477421#M122946</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-07-12T12:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a PROC HTTP Post request by passing a JSON message</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/500078#M133117</link>
      <description>&lt;P&gt;FWIW, I just had to solve the same problem and did it by masking the json body with the nrbquote function and&amp;nbsp;passing that to&amp;nbsp;the IN parameter of the proc http, like so (where &amp;amp;pi_request_body contains a valid json object):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  %let body = %nrbquote(&amp;amp;pi_request_body.);

  proc http
    url="&amp;amp;server./piwebapi/batch"
    method="POST"
    ct="application/json"
    in="&amp;amp;body."
    out=&amp;amp;pi_response_file.;
    headers "Authorization"="Bearer &amp;amp;pi_token.";
  run;&lt;/PRE&gt;&lt;P&gt;HTH, Robin Barendregt&lt;/P&gt;</description>
      <pubDate>Sat, 29 Sep 2018 06:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/500078#M133117</guid>
      <dc:creator>quixotik</dc:creator>
      <dc:date>2018-09-29T06:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a PROC HTTP Post request by passing a JSON message</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/667332#M199802</link>
      <description>I am doing similar post request and got 503 error code service unavailable&lt;BR /&gt;What is the possible reason doe that error?&lt;BR /&gt;Need a little help for debug by using 9.4m3 what options do I have?</description>
      <pubDate>Tue, 07 Jul 2020 01:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/667332#M199802</guid>
      <dc:creator>niejung</dc:creator>
      <dc:date>2020-07-07T01:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a PROC HTTP Post request by passing a JSON message</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/667419#M199859</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/336655"&gt;@niejung&lt;/a&gt;&amp;nbsp;HTTP 503 is "Service Unavailable" -- which suggests the API you're calling is not available, or the URL you're using is incorrect.&amp;nbsp; I suggest that you try the call in Postman or cURL -- removing SAS from the equation -- until you can verify the call is working.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 12:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-PROC-HTTP-Post-request-by-passing-a-JSON-message/m-p/667419#M199859</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2020-07-07T12:03:20Z</dc:date>
    </item>
  </channel>
</rss>

