<?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 body data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810283#M81790</link>
    <description>&lt;P&gt;Is there another way to pass this data, perhaps on the URL string as URL-encoded data? That would be a more standard method for passing data to a GET method.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Apr 2022 22:30:04 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2022-04-27T22:30:04Z</dc:date>
    <item>
      <title>PROC HTTP body data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810011#M81782</link>
      <description>&lt;P&gt;I'm able to use Postman to connect to an API with some body data and get back a specific version of response data (based on the info passed in the body data). When I try to do the same using PROC HTTP in SAS, I cannot get back the version of response data I've specified. I assume it's because I'm not doing something right in my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let service_url=&lt;A href="https://abc.com/service" target="_blank"&gt;https://abc.com/service&lt;/A&gt;();&lt;BR /&gt;filename head_out "D:\test.txt";&lt;BR /&gt;filename json_out "D:\test.json";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc http&lt;BR /&gt;url="&amp;amp;service_url"&lt;BR /&gt;method="GET"&lt;BR /&gt;WEBUSERNAME="uid"&lt;BR /&gt;WEBPASSWORD="pwd"&lt;BR /&gt;AUTH_BASIC&lt;BR /&gt;in='{"version": {"major": "01", "minor": "03", "patch": "00"}}'&lt;BR /&gt;headerout=head_out&lt;BR /&gt;out=json_out&amp;nbsp;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code runs fine &amp;amp; w/o errors. It just returns the default version of the data (1.2.1) instead of the (1.3.0) version specified in the json in the in statement. In Postman, I get version (1.3.0) as I should. Is there something I'm missing? I've tried messing around with the headers (Content-Type) some but nothing I've tried has worked.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 20:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810011#M81782</guid>
      <dc:creator>jreichert</dc:creator>
      <dc:date>2022-04-26T20:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP body data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810018#M81783</link>
      <description>&lt;P&gt;I don't know your API but is it possible you need the braces?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc http
url="&amp;amp;service_url"
method="GET"
WEBUSERNAME="uid"
WEBPASSWORD="pwd"
AUTH_BASIC
in='[{"version": {"major": "01", "minor": "03", "patch": "00"}}]'
headerout=head_out
out=json_out ;
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that's not it, grab the cURL code the Postman can generate for you (it can generate code in a number scripting formats but not SAS, unfortunately) and paste it here (sanitize the URL and sensitive fields, of course).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 21:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810018#M81783</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-04-26T21:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP body data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810135#M81784</link>
      <description>&lt;P&gt;Thanks Chris, unfortunately the braces didn't work. Here's the generated cURL code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;curl --location --request GET '&lt;A href="https://abc.com/service" target="_blank"&gt;https://abc.com/service&lt;/A&gt;()' \&lt;BR /&gt;--header 'Authorization: Basic Ym9wMDAyMjg6SnVhblNvdG8jMjJNVlA=' \&lt;BR /&gt;--header 'Content-Type: text/plain' \&lt;BR /&gt;--header 'Cookie: xxxxx=0000HrDnccO3VbQV28Yp000TjT1:C3F02A179384BB400000031C000084440A0C0119; yyyyy=a0xZZUF/E6UoDhvt9rVpOf6yaD+ihUem0lEakU6eo30HmK7' \&lt;BR /&gt;--data-raw '{"version": {"major": "01", "minor": "03", "patch": "00"}}'&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 12:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810135#M81784</guid>
      <dc:creator>jreichert</dc:creator>
      <dc:date>2022-04-27T12:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP body data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810143#M81785</link>
      <description>&lt;P&gt;Okay, then you should use something like this (not webuser/password):&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;filename resp temp;
proc http
 url="https://abc.com/service()"
 in =  '{"version": {"major": "01", "minor": "03", "patch": "00"}}'
 out=resp
 ct="text/plain";
;
 headers "Authorization" = "Basic Ym9wMDAyMjg6SnVhblNvdG8jMjJNVlA=";
run;

/* print JSON resp to log */
data _null_;
 rc=jsonpp('resp','log');
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 13:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810143#M81785</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-04-27T13:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP body data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810209#M81786</link>
      <description>&lt;P&gt;I tried as you suggest &amp;amp; still no luck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had to add/use ‘method=”GET”’ to the code to override the default “PUT” method. The developer of the API specifically said to use “GET” and I get a 405 error with “PUT.”&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know if SAS somehow defaults to ignoring the in=/body data if the “GET” method is used? I’m not well versed with APIs, but it sounds like in=/body data is mostly used with “PUT” methods to insert new data, so I could see what I need to do as something of an outlier.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also do you know of a way to confirm that the in=/body data has been read in? I’ve tried using “debug level=3” in my code &amp;amp; can see info in the log about the Authorization: header and Content-Type: but nothing about the in=/body data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for all you help. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 16:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810209#M81786</guid>
      <dc:creator>jreichert</dc:creator>
      <dc:date>2022-04-27T16:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP body data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810216#M81787</link>
      <description>&lt;P&gt;Good points about the IN= (or body) implying a PUT or POST. Are you sure that the API uses GET&amp;nbsp;&lt;STRONG&gt;and&lt;/STRONG&gt; expects a body? Is this API documented somewhere on the internet that I can see?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 16:34:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810216#M81787</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-04-27T16:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP body data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810250#M81788</link>
      <description>&lt;P&gt;Sorry the default is POST (not PUT, confusing my P words).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Unfortunately the API is internal to my organization. The developer definitely told me to use “GET” and the “GET” works in Postman.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;From my understanding of it, the version data in the body just tells the API what version of a calculation to perform &amp;amp; then returns the data in a JSON file. When I run it in Postman, the version info in the return data says 1.3.0. When I run it in SAS, the version info in the return data says 1.2.1 which is the default/current version. So it’s like it didn’t receive/recognize the in=/body data I’m trying to send.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 17:52:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810250#M81788</guid>
      <dc:creator>jreichert</dc:creator>
      <dc:date>2022-04-27T17:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP body data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810282#M81789</link>
      <description>&lt;P&gt;I think that PROC HTTP is not passing the IN= content when the GET method is used. We could get all self-righteous and &lt;A href="https://www.rfc-editor.org/rfc/rfc7231#page-24" target="_self"&gt;point to the HTTP spec&lt;/A&gt; that says that a payload on the GET method has no semantic meaning:&lt;/P&gt;
&lt;PRE class="newpage"&gt;   A payload within a GET request message has no defined semantics;
   sending a payload body on a GET request might cause some existing
   implementations to reject the request.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;But that's little comfort if your developer built the API this way and cannot/won't change it. The fact that some tools support sending it doesn't make it right, and PROC HTTP might be a little overzealous by not passing it along.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 22:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810282#M81789</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-04-27T22:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP body data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810283#M81790</link>
      <description>&lt;P&gt;Is there another way to pass this data, perhaps on the URL string as URL-encoded data? That would be a more standard method for passing data to a GET method.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 22:30:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810283#M81790</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-04-27T22:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: PROC HTTP body data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810397#M81792</link>
      <description>&lt;P&gt;I sent an email to our developer to see if there was any other way of passing the data. As of yet, I haven't heard anything back - I believe he's on vacation this week.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If he can't/won't offer up another way, I hope (with the help of a co-worker) to be able to use some combo of SAS &amp;amp; Python to get the version of the response data I need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for all your time, effort &amp;amp; help!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-HTTP-body-data/m-p/810397#M81792</guid>
      <dc:creator>jreichert</dc:creator>
      <dc:date>2022-04-28T15:36:14Z</dc:date>
    </item>
  </channel>
</rss>

