title: Getting 405 "Method Not Allowed" error using POST with @FormParam (Java web service with Jersey REST)
body: <p>I know it is not easy to pass something to the REST Server (Resource) which is neither String nor a simple Type. <br>
  But for a simple ordering process I need to send a list of articles (which shall be ordered) from the client to teh server. </p>
  
  <p>I already tried using "QueryParam", converting my object (I wrapped the list into a DTO) into JSON-String and passing it. It didn't work. (But for other methods which don't need to pass an object to the server my service works fine, even POST methods.)</p>
  
  <p>Then I found out about the @FormParam which can theoretically transfer every kind of object. (That's what I read, is it actually true?)</p>
  
  <p>So I tried in a very simple test method to pass a List of Strings to the Service, the serverside should give back the number of elements of that list.</p>
  
  <p>That's my code:</p>
  
  <p>On Server-Side (Resource):</p>
  
  <pre><code>@Path("bestellung")
  public class BestellungResource {
  
    @Path("test")
    @POST
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    @Produces(XML)
  
    public Integer test(
      @FormParam("list") List&lt;String&gt; list){
  
        return list.size();        
    }
  }
  </code></pre>
  
  <p><br></p>
  
  <p>And on Client Side (in a Session Bean):</p>
  
  <pre><code>public Integer  test() {
  
      List&lt;String&gt; list = new ArrayList&lt;String&gt;();
      list.add("1");
      list.add("2");
      list.add("3");
  
      Form form = new Form();
      form.add("list", list);
  
      return service
               .path("bestellung")
               .path("test")
               .type(MediaType.APPLICATION_FORM_URLENCODED)
               .post(Integer.class, form);
  }
  </code></pre>
  
  <p>Where <strong>service</strong> is built like that:</p>
  
  <pre><code>ClientConfig config = new DefaultClientConfig();
  Client client = Client.create(config);
  service = client.resource(UriBuilder.fromUri("&lt;service url&gt;").build());
  </code></pre>
  
  <p>Invoking this client method from my GUI or directly via EJB Explorer always gives the 405 error.</p>
  
  <p>Where's the problem? Did I miss something with POST, the MIME types or the Form?</p>
  
  <p>By the way, even with simple form parameters like a String or int it does not work and throws a 405 error as well.</p>
  
  <p>Thanks for your help!<br>
  Jana</p>