title: Making a HTTP POST SOAP request with JSON
body: <p>I am making a SOAP request to a web method using HTTP Post. The request and response are both JSON.</p>
  
  <p>But while making the POST request i am getting an error : </p>
  
  <blockquote>
    <p>The server cannot service the request because the media type is
    unsupported.</p>
  </blockquote>
  
  <p>This is my code</p>
  
  <pre><code>String SOAP_ACTION = "Method name";
  String URL = "service url";
  HttpPost httpPost = null;
  
  httpPost = new HttpPost(URL);
  httpPost.addHeader("Accept-Encoding", "gzip,deflate");
  httpPost.addHeader("Content-Type", "application/json; charset=UTF-8");
  httpPost.addHeader("SOAPAction", SOAP_ACTION);
  
  HttpEntity postEntity = new StringEntity(requestContent);
  httpPost.setEntity(postEntity);
  </code></pre>
  
  <p>I have tried giving Accept-Encoding as application/json , text. But i still get the same error.</p>