<?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: JSON based stored process works fine in SAS stpweb app but returns NO data while using API call in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/m-p/394873#M277891</link>
    <description>&lt;P&gt;Many thanks for your timely help!&lt;/P&gt;</description>
    <pubDate>Mon, 11 Sep 2017 19:41:09 GMT</pubDate>
    <dc:creator>saspert</dc:creator>
    <dc:date>2017-09-11T19:41:09Z</dc:date>
    <item>
      <title>JSON based stored process works fine in SAS stpweb app but returns NO data while using API call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/m-p/394032#M277887</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a stored process web app hosted on a AWS server. My json based stored process works fine on the stored process web app. But when I make an API call using postman/soapui, I get a 200 OK message but no data back.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://myserver.compute-1.amazonaws.com:8343/SASBIWS/rest/storedProcesses/Products/xyz/scr2json" target="_blank"&gt;https://myserver.compute-1.amazonaws.com:8343/SASBIWS/rest/storedProcesses/Products/xyz/scr2json&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;is the endpoint I am using.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the header information I am passing-&lt;/P&gt;
&lt;P&gt;Accept: application/json&lt;/P&gt;
&lt;P&gt;Content-Type:&amp;nbsp;application/x-www-form-urlencoded&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When using SOAPUI, I give the username/password on the request properties. Before that I create a new REST request using the above end point and just click on it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I am using postman, I plug in the above URL, the header information noted above and also the username and password.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; old = stpsrv_header("Content-type","application/json");&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;options symbolgen mlogic mprint mprintnest merror ;&lt;/P&gt;
&lt;P&gt;libname _webout xml ;&lt;BR /&gt;libname abcd '/mnt/data/SP';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let survey_key=501;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table ctgry_trgt_scrn as&lt;BR /&gt;select target_id, category_id, target_name, category_name&lt;BR /&gt;from abcd.survey_target_category&lt;BR /&gt;where survey_key=input("&amp;amp;survey_key.",4.);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;options nosyntaxcheck;&lt;/P&gt;
&lt;P&gt;proc json out=_webout pretty nosastags;&lt;BR /&gt;write open object;&lt;BR /&gt;write values "rows";&lt;BR /&gt;write open array;&lt;BR /&gt;export ctgry_trgt_scrn;&lt;BR /&gt;write close;&lt;BR /&gt;write close;&lt;BR /&gt;run;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 20:02:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/m-p/394032#M277887</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2017-09-07T20:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: JSON based stored process works fine in SAS stpweb app but returns NO data while using API call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/m-p/394141#M277888</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you defined data targets in the Metadata of the Stored Process.&lt;/P&gt;
&lt;P&gt;By default call a STP as Web Service will return the output parameters defined as a JSON structure.&lt;/P&gt;
&lt;P&gt;To access other data, you will need to define a data target and use a different end point to call your STP as Web Service.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will find a quick introduction on using a Stored Process as a Web Service on this page&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sas.com/de_de/training/home/services/webinar-lunchtime.html" target="_self"&gt;https://www.sas.com/de_de/training/home/services/webinar-lunchtime.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Search for "&lt;STRONG&gt;Stored Processes als Web-/REST-Service aufrufen&lt;/STRONG&gt;"&lt;/P&gt;
&lt;P&gt;You can download the slides and sample STP and SAS program code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The slides are in German, I hope this gets you going.&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, 08 Sep 2017 06:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/m-p/394141#M277888</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-09-08T06:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: JSON based stored process works fine in SAS stpweb app but returns NO data while using API call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/m-p/394259#M277889</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32"&gt;@BrunoMueller&lt;/a&gt; this is a great suggestion! So I did add the entry into the stored process and also the additional endpoint to the web service -&lt;/P&gt;
&lt;P&gt;&lt;A href="https://myserver.compute-1.amazonaws.com/SASBIWS/json/storedProcesses/Products/myclient/scr2json/dataTargets/myjson" target="_blank"&gt;https://myserver.compute-1.amazonaws.com/SASBIWS/json/storedProcesses/Products/myclient/scr2json/dataTargets/myjson&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I have the header inside the stored process set to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;/*&amp;nbsp;&amp;nbsp;&amp;nbsp; old = stpsrv_header("Content-type","application/json");*/&lt;BR /&gt;/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; old = stpsrv_header("Accept","application/json");*/&lt;BR /&gt;&amp;nbsp;&amp;nbsp;new=stpsrv_header("Content-type","application/x-www-form-urlencoded");&lt;BR /&gt;/*old=stpsrv_header("Content-type","application/json");*/&lt;/P&gt;
&lt;P&gt;/*&amp;nbsp;abc=stpsrv_header("Content-type","application/x-www-form-urlencoded");*/&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and the soapui header to this -&lt;/P&gt;
&lt;P&gt;Accept &amp;nbsp;application/json&lt;/P&gt;
&lt;P&gt;Content-type&amp;nbsp;application/x-www-form-urlencoded&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but now I get&amp;nbsp;&amp;gt;HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException error. I using a GET method using SOAPUI&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please point out if I need to change the header in my code and/or soapui request.&amp;nbsp;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 16:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/m-p/394259#M277889</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2017-09-08T16:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: JSON based stored process works fine in SAS stpweb app but returns NO data while using API call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/m-p/394275#M277890</link>
      <description>&lt;P&gt;In my example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I first write out the JSON to a temp file and use the DATA Step to stream it back to the appropriate fileref as defined in the data targets of the stored process metadata. Like so:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename xjson temp;

proc json out=xjson pretty;
   export &amp;amp;tableName;
run;

data _null_;
  infile xjson;
  input;
  file myjson;
  put _infile_;
run;

filename xjson clear;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I do use the %STPBEGIN and %STPEND macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not set the application header&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can download the sample STP and Proc HTTP code to call the Web Service from the web site I mentioned earlier&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;also note, that if your SAS code has an error, you get the code 500, also check the Stored Process Server Log&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 17:05:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/m-p/394275#M277890</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-09-08T17:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: JSON based stored process works fine in SAS stpweb app but returns NO data while using API call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/m-p/394873#M277891</link>
      <description>&lt;P&gt;Many thanks for your timely help!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 19:41:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/JSON-based-stored-process-works-fine-in-SAS-stpweb-app-but/m-p/394873#M277891</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2017-09-11T19:41:09Z</dc:date>
    </item>
  </channel>
</rss>

