Hi everyone
I've tried to use proc http to call intelligent decision api in sas studio but it I didn't got expected response as I got in postman. It showed 415 unsupported media type in log tab. Do yo guys know how to fix it? please let me know.
response in postman
What I've tried; all I got was 415 unsupported media type
1.
filename rept temp;
proc http
url = &url.
out = rept
method = "post"
in = form ("Fg_1m_6m_"="0"
"Fg_2m_6m_"="0"
"Wd_3m_"="0"
"AvgOut_3m_6m_"="0.25713"
"Avgdr_9m_"="0.11111"
"TermOverDueAR_"="0");
headers
"Authorization" = &token.;
run;
2.
filename rept temp;
proc http
url = &url.
out = rept
method = "post"
in='{"inputs":[{"name": "Fg_1m_6m_", "value": 0},{"name": "Fg_2m_6m_", "value": 0},{"name": "Wd_3m_", "value": 0},{"name": "AvgOut_3m_6m_", "value": 0.25713},{"name": "Avgdr_9m_", "value": 0.11111},{"name": "TermOverDueAR_", "value": 0}]}';
headers
"Authorization" = &token.;
run;
3.
filename rept temp;
proc http
url = &url.
out = rept
method = "post"
in= 'Fg_1m_6m_=0&Fg_2m_6m_=0&Wd_3m_=0&AvgOut_3m_6m_=0.25713&Avgdr_9m_=0.11111&TermOverDueAR_=0';
headers
"Authorization" = &token.;
run;
4.
filename json_in temp;
data _null_;
file json_in;
input;
put _infile_;
datalines;
{"Fg_1m_6m_":0}
{"Fg_2m_6m_":0}
{"Wd_3m_":0}
{"AvgOut_3m_6m_":0.25713}
{Avgdr_9m_":0.11111}
{"TermOverDueAR_":0}
;
run;
filename rept temp;
proc http
url = &url.
out = rept
method = "post"
in =json_in;
headers
"Authorization" = &token.;
run;
5.
filename rept temp;
proc http
url = &url.
out = rept
method = "post"
in= 'Fg_1m_6m_=0&Fg_2m_6m_=0&Wd_3m_=0&AvgOut_3m_6m_=0.25713&Avgdr_9m_=0.11111&TermOverDueAR_=0';
headers
"Authorization" = &token.;
run;
6.
filename json_in TEMP;
data _null_;
file json_in;
put '{';
put '"name": "Fg_1m_6m_", "value": 0,';
put '"name": "Fg_2m_6m_", "value": 0,';
put '"name": "Wd_3m_", "value": 0,';
put '"name": "AvgOut_3m_6m_", "value": 0.25713,';
put '"name": "Avgdr_9m_", "value": 0.11111,';
put '"name": "TermOverDueAR_", "value": 0,';
put '}';
run;
filename resp TEMP;
proc http
METHOD="POST"
url=&url.
in=json_in
out=resp
oauth_bearer = sas_services;
headers 'Authorization'= &token;
run;
libname resp clear;
libname resp json;
7.
filename resp TEMP;
proc http METHOD="POST"
url=&url.
in='{"name": "Fg_1m_6m_", "value": 0},{"name": "Fg_2m_6m_", "value": 0},{"name": "Wd_3m_", "value": 0},{"name": "AvgOut_3m_6m_", "value": 0.25713},{"name": "Avgdr_9m_", "value": 0.11111},{"name": "TermOverDueAR_", "value": 0}'
out=resp
oauth_bearer = sas_services;
headers 'Authorization'=&token.;
run;
libname resp clear;
libname resp json;
Of the examples you provided, #2 looks the closest/most correct. The PROC HTTP data should be the same JSON you supply in Postman. Also, be sure to add the CT= option for this call to tell the API what to expect:
'Content-Type': 'application/vnd.sas.microanalytic.module.step.input+json'
Of the examples you provided, #2 looks the closest/most correct. The PROC HTTP data should be the same JSON you supply in Postman. Also, be sure to add the CT= option for this call to tell the API what to expect:
'Content-Type': 'application/vnd.sas.microanalytic.module.step.input+json'
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.