415 Unsupported Media Type For Xml Post Rest Api
I am trying to Request for REST POST API with XML string but I am getting following error response.
Solution 1:
Did you try without charset="utf-8"?
(I couldn't leave a comment due to my low reputation)
Solution 2:
In your request you are specifying the communication to be soap-xml
httpRequest.setHeader("Content-Type","application/soap-xml;charset=UTF-8");
Try to specify to use plain xml by removing the "soap" part.
Valid xml content types:
"text/xml" or "application/xml"
Soap calls are very specifically formatted xml and from the response, unless you trimmed the output to remove all of the soap xml, it appears to be a plain xml service.
Solution 3:
If you use @Consumes(MediaType.APPLICATION_XML)
in your REST service then use content type as follows
httpRequest.setHeader("Content-Type","application/xml;");
Check you application using browser REST clients such as Curl, Advanced rest clent, etc.
Post a Comment for "415 Unsupported Media Type For Xml Post Rest Api"