<?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: creating json rest API in Developers</title>
    <link>https://communities.sas.com/t5/Developers/creating-json-rest-API/m-p/390140#M5477</link>
    <description>&lt;P&gt;Hello Mathias,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a perfectly valid way of coding a web service yourself. You also have valid concerns.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are a few takeway notes:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Your web service works becasue you have manually logged on. Try to log out of SAS Stored Process Web Application and run the request, it will not work becasue SAS will ask you to authenticate when your ajax request won't handle that request.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Your way of changing headers applies only to your webservice. This means you can't use the same method to log in to your webservice as SAS Logon manager will not have the correct headers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Default setting for SAS Web Server is to time out after one minute. It can be changed, but at the same time, would your users wait for at least 30 seconds to refresh a datasource on the screen? If web service takes more then a few seconds to fetch the data, something needs to change.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two solutions to suggest:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Consider using an open source connector form Boemska:&amp;nbsp;&lt;A href="https://github.com/Boemska/h54s" target="_blank"&gt;https://github.com/Boemska/h54s&lt;/A&gt; This is tried and tested way of getting data out SAS, but it requires certain level of access to the SAS platform.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Analytium, the company that I am working for, has a solution in the pipeline that makes it easier to integrate software with SAS. It would be great if I could give you a quick demo over WebEx to see how Analytium could help you get the most out SAS. If you are interested, just let me know your timezone, availability&amp;nbsp;and email by sending me a private message: &lt;A href="https://communities.sas.com/t5/notes/privatenotespage/tab/compose/note-to-user-id/50837" target="_self"&gt;Send Message to Vasilij Nevlev&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Vasilij&lt;/P&gt;</description>
    <pubDate>Wed, 23 Aug 2017 08:25:43 GMT</pubDate>
    <dc:creator>VasilijNevlev</dc:creator>
    <dc:date>2017-08-23T08:25:43Z</dc:date>
    <item>
      <title>creating json rest API</title>
      <link>https://communities.sas.com/t5/Developers/creating-json-rest-API/m-p/389739#M5475</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to expose some data one the web through a json rest api.&lt;/P&gt;
&lt;P&gt;I have no idea how it could be done. (I have experience building Stored processes with SAS EG (EG 7.1 &amp;amp; SAS 9.3)&amp;nbsp;but&amp;nbsp;that's about it)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it as simple as making a STP like this?&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;data _null_;
     file _webout;
     put '...';&amp;nbsp; 
     run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried that and when going to the url of the STP in a browser I see the json data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But when retrieving the data with javascript from a web page on another server I get a cross-origin CORS error.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;XMLHttpRequest cannot load &lt;A href="https://xxx.xxx.xxx/SASStoredProcess/guest?_program=/yyy/yyy/yyy" target="_blank"&gt;https://xxx.xxx.xxx/SASStoredProcess/guest?_program=/yyy/yyy/yyy&lt;/A&gt;. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '&lt;A href="https://xxx.xxx.xxx" target="_blank"&gt;https://xxx.xxx.xxx&lt;/A&gt;' is therefore not allowed access.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;$.ajax({
	dataType: "json",
	url: "//xxx.xxx.xxx/SASStoredProcess/guest?_program=/yyy/yyy/yyy",
	// data: data,
	success: function(data) {
		console.log(data);
	}
});
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to add the header "&lt;SPAN&gt;Access-Control-Allow-Origin:*" in the response&lt;/SPAN&gt;?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2018 09:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/creating-json-rest-API/m-p/389739#M5475</guid>
      <dc:creator>mathias</dc:creator>
      <dc:date>2018-08-24T09:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: creating json rest API</title>
      <link>https://communities.sas.com/t5/Developers/creating-json-rest-API/m-p/389744#M5476</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Still have no idea if this is a good way for achieving this.&lt;/P&gt;
&lt;P&gt;What happens when the STP gets more complicated and takes more than a fraction of a second to complete?&lt;/P&gt;
&lt;P&gt;Is this REST?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2018 09:53:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/creating-json-rest-API/m-p/389744#M5476</guid>
      <dc:creator>mathias</dc:creator>
      <dc:date>2018-08-24T09:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: creating json rest API</title>
      <link>https://communities.sas.com/t5/Developers/creating-json-rest-API/m-p/390140#M5477</link>
      <description>&lt;P&gt;Hello Mathias,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a perfectly valid way of coding a web service yourself. You also have valid concerns.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are a few takeway notes:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Your web service works becasue you have manually logged on. Try to log out of SAS Stored Process Web Application and run the request, it will not work becasue SAS will ask you to authenticate when your ajax request won't handle that request.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Your way of changing headers applies only to your webservice. This means you can't use the same method to log in to your webservice as SAS Logon manager will not have the correct headers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Default setting for SAS Web Server is to time out after one minute. It can be changed, but at the same time, would your users wait for at least 30 seconds to refresh a datasource on the screen? If web service takes more then a few seconds to fetch the data, something needs to change.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two solutions to suggest:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Consider using an open source connector form Boemska:&amp;nbsp;&lt;A href="https://github.com/Boemska/h54s" target="_blank"&gt;https://github.com/Boemska/h54s&lt;/A&gt; This is tried and tested way of getting data out SAS, but it requires certain level of access to the SAS platform.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Analytium, the company that I am working for, has a solution in the pipeline that makes it easier to integrate software with SAS. It would be great if I could give you a quick demo over WebEx to see how Analytium could help you get the most out SAS. If you are interested, just let me know your timezone, availability&amp;nbsp;and email by sending me a private message: &lt;A href="https://communities.sas.com/t5/notes/privatenotespage/tab/compose/note-to-user-id/50837" target="_self"&gt;Send Message to Vasilij Nevlev&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Vasilij&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 08:25:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/creating-json-rest-API/m-p/390140#M5477</guid>
      <dc:creator>VasilijNevlev</dc:creator>
      <dc:date>2017-08-23T08:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: creating json rest API</title>
      <link>https://communities.sas.com/t5/Developers/creating-json-rest-API/m-p/394023#M5478</link>
      <description>&lt;P&gt;See if this helps. We ran into a CORS on a AWS server hosting the sas stored process web app.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/59/957.html" target="_blank"&gt;http://support.sas.com/kb/59/957.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 19:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/creating-json-rest-API/m-p/394023#M5478</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2017-09-07T19:49:21Z</dc:date>
    </item>
  </channel>
</rss>

