<?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: using http methods in SAS ds2 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911566#M359450</link>
    <description>&lt;P&gt;That's the fun part.&amp;nbsp; I'm getting warnings, but at some point its hitting some limit, and displaying the message I've included.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jan 2024 14:41:44 GMT</pubDate>
    <dc:creator>noffer</dc:creator>
    <dc:date>2024-01-15T14:41:44Z</dc:date>
    <item>
      <title>using http methods in SAS ds2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911451#M359404</link>
      <description>&lt;P&gt;Hi, I have a working ds2 prototype that does http posts to a service.&amp;nbsp; Here's the working code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;    /* HTTP POST in DS2, requests sent iteratively */
	proc ds2;
	data _null_;
		method init();
		end;
		method call_service(varchar(256) consUrlBase, varchar(256) uuid, varchar(256) brand, varchar(100) definition, varchar(2048) auth_token);
			filename response temp;
			filename request temp;
			dcl varchar(2050) authHeader;
			dcl varchar(1024) consUrl;
			dcl varchar(255) consPart jsonBody;
    		dcl package http h();
			dcl varchar(1024) body;
			dcl int status;
			dcl varchar(1024) contentType;

			
			/* set a couple variables*/

			/* use http package to call service */
			h.createPostMethod(consUrl);
			h.setOAuthToken(authHeader);
			/* set a couple headers */
			h.setRequestContentType('application/json; charset=utf-8');
			h.setRequestBodyAsString(jsonBody);
			h.executeMethod();
			status = h.getStatusCode();
			if status ^= 201 then do;
      			put 'ERROR: ' status ' response calling ' consUrl;
			end;
			h.delete();
			end;
		method run(); /* run step executes for each row in dataset */
			set work_dir.&amp;amp;dsname._&amp;amp;currdate.;
			call_service(cons_url_base, UUID, brnd_name, definition, auth_token);
			end;
		method term();
			put 'Done with ds2 logic!';
			end;
	enddata;
	run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So the code executes and I get the 201 response I'm expecting.&amp;nbsp; Except I'm also getting the following warning...&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;WARNING: Warning reported by DS2 package d2http:
WARNING: Aborted execution of HTTP POST method with URL: &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;After 500 messages (or so it seems), I get:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;ERROR: Maximum number of error messages that can be recorded has been exceeded.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'll routinely process thousands of records, so looking for a way to suppress the warning as it is causing the program to fail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm also slightly suspicious of the &lt;CODE class=""&gt;dcl package http h();&lt;/CODE&gt; ... maybe that should just be declared globally?&amp;nbsp; I'm not seeing any performance improvement by moving it.&amp;nbsp; (real time was slower, cpu time was less) I'm just following the sample code found &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/ds2ref/n1nda7jhzcxnoin1knkwi8jbikf6.htm" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;and other posts, so open to any guidance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 21:23:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911451#M359404</guid>
      <dc:creator>noffer</dc:creator>
      <dc:date>2024-01-12T21:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: using http methods in SAS ds2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911478#M359415</link>
      <description>&lt;P&gt;What is the error message you are getting?&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2024 16:53:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911478#M359415</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-13T16:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: using http methods in SAS ds2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911566#M359450</link>
      <description>&lt;P&gt;That's the fun part.&amp;nbsp; I'm getting warnings, but at some point its hitting some limit, and displaying the message I've included.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 14:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911566#M359450</guid>
      <dc:creator>noffer</dc:creator>
      <dc:date>2024-01-15T14:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: using http methods in SAS ds2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911582#M359452</link>
      <description>&lt;P&gt;Is there any reason why you are using DS2 for this?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you seem to be making a new HTTP object for each observation?&amp;nbsp; Can't you reuse a single object?&amp;nbsp; Are you trying to have DS2 make multiple HTTP requests at the same time?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 16:31:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911582#M359452</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-15T16:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: using http methods in SAS ds2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911585#M359454</link>
      <description>&lt;P&gt;Using ds2 as this will move into a multi-threaded approach like &lt;A href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/ds2pg/p0qykqw1fdra8dn1449vxg9ydfkk.htm" target="_self"&gt;here&lt;/A&gt;.&amp;nbsp; Yes, I thought to move the instantiation of the http object to a global var, but doesn't seem to make&amp;nbsp; a performance difference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And why not use a proc http? That will make all calls at once, so if I have to make 10k calls, I wouldn't want to make all calls at once.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 18:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911585#M359454</guid>
      <dc:creator>noffer</dc:creator>
      <dc:date>2024-01-15T18:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: using http methods in SAS ds2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911591#M359455</link>
      <description>&lt;P&gt;Are you sure your server can handle that many calls in a short time or that the server doesn't qualify these calls as a potential DoS attack and blocks you?&lt;/P&gt;
&lt;P&gt;It might be worth considering to "combine" the calls and then sort out the response file.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 00:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911591#M359455</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-01-16T00:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: using http methods in SAS ds2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911660#M359477</link>
      <description>&lt;P&gt;Thanks for you reply Patrick.&amp;nbsp; The web service currently processes 10-20k daily in bulk batches.&amp;nbsp; Sometimes a couple hundred thousand, which is why there's some motivation to streamline the process.&amp;nbsp; The current process, written years ago dumps the data to a file, which is then picked up by an external program that iterates through the file.&amp;nbsp; The ask is to move the logic into a multi-threaded SAS proc.&amp;nbsp; It doesn't help much if it throws an error after 500 calls.&amp;nbsp; I've opened a ticket with SAS support to see if there's any options that they can offer.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 15:59:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911660#M359477</guid>
      <dc:creator>noffer</dc:creator>
      <dc:date>2024-01-16T15:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: using http methods in SAS ds2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911662#M359478</link>
      <description>&lt;P&gt;With such volume it is probably worth exploring a different path.&lt;/P&gt;
&lt;P&gt;Can't you just have them create a report that runs directly on the data without the HTTP interface?&lt;/P&gt;
&lt;P&gt;That would be much less burden on everyone (and every system too).&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 16:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911662#M359478</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-16T16:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: using http methods in SAS ds2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911697#M359491</link>
      <description>&lt;P&gt;Solution was to add the following just above the h.delete() ....&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;h.abortMethod();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jan 2024 20:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-http-methods-in-SAS-ds2/m-p/911697#M359491</guid>
      <dc:creator>noffer</dc:creator>
      <dc:date>2024-01-16T20:58:37Z</dc:date>
    </item>
  </channel>
</rss>

