title: Jersey 415 Unsupported Media Type
body: <p>I have been trying since hours to correct http error <code>415 Unsupported Media Type</code> but it is still showing media unsupported page. 
  I am adding headers <code>application/json</code> in Postman.</p>
  
  <p>Here is my Java Code </p>
  
  <pre><code>package lostLove;
  
  import javax.ws.rs.Consumes;
  import javax.ws.rs.GET;  
  import javax.ws.rs.POST;
  import javax.ws.rs.Path;  
  import javax.ws.rs.PathParam;  
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.Response; 
  
  import org.json.JSONObject;
  
  
  @Path("/Story") 
  public class Story {
  
        @POST
        @Consumes({"application/json"})
        @Produces(MediaType.APPLICATION_JSON)
      //  @Consumes(MediaType.APPLICATION_JSON)
      //  @Path("/Story") 
        public JSONObject sayJsonTextHello(JSONObject inputJsonObj) throws Exception {
  
          String input = (String) inputJsonObj.get("input");
          String output = "The input you sent is :" + input;
          JSONObject outputJsonObj = new JSONObject();
          outputJsonObj.put("output", output);
  
          return outputJsonObj;
        }
  
        @GET  
        @Produces(MediaType.TEXT_PLAIN)  
  
        public String sayPlainTextHello() {  
          return "hello";
        }
  
  }
  </code></pre>
  
  <p>here is my <code>web.xml</code> file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;
    &lt;display-name&gt;LostLove&lt;/display-name&gt;
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
   &lt;servlet&gt;  
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;  
      &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;  
      &lt;init-param&gt;  
          &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;  
          &lt;param-value&gt;lostLove&lt;/param-value&gt;  
      &lt;/init-param&gt;  
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;  
    &lt;/servlet&gt;  
    &lt;servlet-mapping&gt;  
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;  
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;  
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>