I am trying to Request for REST POST API with XML string but I am getting following error response.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<apiErrors>
<apiError>
<errorMessage>415 Unsupported Media Type - null</errorMessage>
</apiError>
</apiErrors>
I don't understand why this happening. Even I set content-type and header also.
Please take a look at my code.
String XmlString = "<Contact>"
+"<name>Sandeep</name>"
+"<title>Mr.</title>"
+"<Address>India</Address>"
+"</Contact>";
try {
StringEntity se = new StringEntity(XmlString);
HttpPost httpRequest = new HttpPost("http://abc:xyz123@000.000.000.00:8080/aaa/sample/feed/000001");
httpRequest.setHeader("Content-Type","application/soap-xml;charset=UTF-8");
httpRequest.setHeader("Accept","text/plain");
httpRequest.setEntity(se);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse httpResponse;
httpResponse = httpclient.execute(httpRequest, new BasicHttpContext());
finalres = inputStreamToString(httpResponse.getEntity().getContent())
.toString();
Please give me hint or reference.