BookmarkSubscribeRSS Feed
NY
Fluorite | Level 6 NY
Fluorite | Level 6

Hi Experts,

I have created a stored process with input and output parameters that I'm trying to call using SAS BI Web Services. See the SAS stp code below: 

 

*ProcessBody; 
 
%global BANK 
        CALCULATIONTYPE 
        COMPANYID 
        CUSTOMERID 
        MODELCODE 
        PREVIOUSCALCULATIONDATE 
        PREVIOUSEXPECTEDLOSS 
        PREVIOUSLOSSGIVENDEFAULT 
        PREVIOUSPROBABILITYOFDEFAULT 
        QUESTIONNAIREGRADE; 
 
%STPBEGIN; 
 
*  End EG generated code (do not edit this line); 
 
 
proc printto log=" D:\RiskModels\RestLogs\web_service_test_%sysfunc(today(),yymmdd10.)-%sysfunc(compress(%sysfunc(time( ),time.),":")).log";
   run;

libname srcdata "D:\RiskModels\SourceData";

proc sql noprint;
select distinct Client_LGD format=16.8 into :lgd from srcdata.lgd_table where 
ID =&customerID;
quit;

%let probabilityOfDefault=0.5;
%let lossGivenDefault = &lgd;
%let expectedLoss = %sysevalf(&lgd. * &probabilityOfDefault.);
%let commentCodes = 1,2,3;


*  Begin EG generated code (do not edit this line); 
;*';*";*/;quit; 
%STPEND; 
 
*  End EG generated code (do not edit this line); 

 

 

I'm using Postman to call the stored process in POST method. My endpoint is (I omitted the server name for this example): 

https://server:443/SASBIWS/json/storedProcesses/RiskModels/web_service_test

The format of the request is JSON. See an example of a request below:

 

Body:{"bank":"bank_name","customerID":"12345678","companyID":"12345678","calculationType":"1","modelCode":"111","questionnaireGrade":70.5,"previousCalculationDate":"2022-08-09","previousProbabilityOfDefault":0.6,"previousLossGivenDefault":0.5,"previousExpectedLoss":0.3}

 

When I'm sending the JSON request with the header: "Content-Type: application/json "

the response is: "HTTP Status 415 – Unsupported Media Type".

My request never reaches the storedprocess server, it gets an error from the webserver.

 

So I guess my question is: What is the correct way to call SASBIWS in POST method using a JSON request.

 

Thank you very much,

Nufar.

1 REPLY 1
AllanBowe
Barite | Level 11

We've never deployed or recommended BIWS so I can't answer your question, however I can let you know about an alternative option that may / may not be helpful in your situation (if neither regular Stored Processes nor Viya are amenable options):

 

https://server.sasjs.io

 

This is an MIT open source REST API, with session manager, over Foundation SAS.  Works perfectly with Postman and any other client you can think of.  And if there's something missing, you can of course fork the project and add any features yourself.

 

Disclosure - it's a product built by my team.

 

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 58973 views
  • 1 like
  • 2 in conversation