BookmarkSubscribeRSS Feed
alch
Calcite | Level 5

Hi Experts,

Im trying to get a simple example code to Work. I have a very simple XML file that I want to use as my content body to a SAS webservice that I have exposed.

 

<?xml version="1.0" encoding="utf-8"?>
<onboarding>
	<streams>
		<in_xml>
			<Value>
			<ape:Apply xmlns:ape="http://ape.dfr.dk/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../AutomatedProductEstablishmentService.xsd">			
	<Origin>
		<Agent>Smith</Agent>
		<AgentReference>1234</AgentReference>
	</Origin>
	<Context>Onboarding</Context>
	<MainApplicant>
		<SocialSecurityNumber>1234567891</SocialSecurityNumber>
		<FirstName>My</FirstName>
		<LastName>Man</LastName>
		<StreetAddress>Gadevej 1</StreetAddress>
		<PostalCode>1234</PostalCode>
		<City>City2</City>
		<MobileNumber>20200202</MobileNumber>
		<Email>mymail@gmail.com</Email>
	</MainApplicant>
</ape:Apply>
</Value>
		</in_xml>
	</streams>
</onboarding>
proc http 
	url			= 'http://<hostname>/SASBIWS/rest/storedProcesses/STP/AML/onboarding' 
	method 		= 'POST'
	in			= payload
	out			= response
	headerout	= head_out
	verbose
	;
	headers 'Content-Type' 	= 'text/xml'
	;
run;

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

 

NOTE: Macro variable SYS_PROC_HTTP_CACHE created for PROC HTTP System cache.
URL                  =
http://<hostname>/SASBIWS/rest/storedProcesses/STP/AML/onboarding
METHOD               = POST
In                   = \\<fileshare>\AML-T-SHARE\SAS\Realtime
CDD\OneDrive\resources\2020.05.07_from_Ali\Onboarding Lite 1 + 2.AlexVersion.xml
Out                  = C:\Users\u3199\AppData\Local\Temp\SAS Temporary
Files\_TD12888_SDCF2707_\#LN00011
Header Out           = C:\Users\u3199\AppData\Local\Temp\SAS Temporary
Files\_TD12888_SDCF2707_\#LN00010

45       headers 'Content-Type'  = 'text/xml'
46       ;
Setting Header: Content-Type: text/xml
47   run;

NOTE: PROCEDURE HTTP used (Total process time):
      real time           0.37 seconds
      cpu time            0.01 seconds

NOTE: 415 Unsupported Media Type

Any idea what i might be doing wrong here?

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

The cause seems quite clear: the content you are sending is not what is expected.

" A 415 Unsupported Media Type error occurs when the origin server refuses a particular request since the resource is in a format that is not supported by the server for the HTTP method used. This unsupported format type issue can be caused by what is defined in the resource's Content-Type or Content-Encoding headers. "

alch
Calcite | Level 5

Hi Chris,

 

Thank you for the reply!

 

I just dont understand why the server is saying this. Im sending XML in the payload and I have set the header for the request to content-Type = text/XML. The STP is registered with a data instream that requires text/XML input data. Where do I need to make a change?

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
  • 1760 views
  • 0 likes
  • 2 in conversation