title: How to POST a form using Jersey 2.0
body: <p>I am trying to get some data from a Form with jersey and i though it would be an easy task to accomplish, however I am getting an error when I try to POST something.</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: The @FormParam is utilized when the content type of the request entity is not application/x-www-form-urlencoded
  at org.glassfish.jersey.server.internal.inject.FormParamValueFactoryProvider$FormParamValueFactory.ensureValidRequest(FormParamValueFactoryProvider.java:126)
  at org.glassfish.jersey.server.internal.inject.FormParamValueFactoryProvider$FormParamValueFactory.getForm(FormParamValueFactoryProvider.java:111)
  at org.glassfish.jersey.server.internal.inject.FormParamValueFactoryProvider$FormParamValueFactory.get(FormParamValueFactoryProvider.java:94)
  at org.glassfish.jersey.server.internal.inject.AbstractHttpContextValueFactory.provide(AbstractHttpContextValueFactory.java:65)
  at org.glassfish.jersey.server.spi.internal.ParameterValueHelper.getParameterValues(ParameterValueHelper.java:80)
  ... 36 more
  </code></pre>
  
  <p>I think this is the relevant part of the stack trace.
  Now for the code I am using:</p>
  
  <pre><code>@POST
  @Path("/delete")
  @Produces("application/json")
  public String delete(@FormParam("id")String id){
  </code></pre>
  
  <p>And I am trying to POST using a test html page like this:</p>
  
  <pre><code>&lt;form action="&lt;path to the server&gt;/delete" method="post"&gt;
      primary_id: &lt;input type="text" name="primary_id" /&gt;&lt;br /&gt;
      &lt;input type="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I've been trying to make it work but no chance. I have tried adding the @Consumes() annotation with multipart-form-data but can't really make it work. I hope someone can give me a hand.</p>