BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Mayt
Obsidian | Level 7

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

Mayt_0-1690431657287.png

 

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;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

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'

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

2 REPLIES 2
ChrisHemedinger
Community Manager

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'

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Mayt
Obsidian | Level 7
It worked!! Thank you very much.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 716 views
  • 2 likes
  • 2 in conversation