This is the error I am getting when I post a JSON as json.toString()
Am stuck with this problem. Need help to overcome this as early as possible
Error code -415
Unsupported Media Type.
Code is
String url = "http://0.0.0.0:0000/XXXX/XXXX?wsdl";
HttpClient client=new DefaultHttpClient();
HttpPost post = new HttpPost(url);
post.setHeader("Accept", "application/json");
post.setHeader("headerValue", "HeaderInformation");
//setting json object to post request.
JSONObject jsonObject=jsonValue();
if(jsonObject!=null ){
StringEntity entity = new StringEntity(jsonObject.toString(), "UTF8");
entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
post.setEntity(entity);
//this is your response:
HttpResponse response = client.execute(post);
System.out.println("Response: " + response.getStatusLine());
System.out.println(response.getStatusLine().toString());
}else{
System.out.println("jsonObject is Empty");