title: How to send enclose data in DELETE request in Jersey client?
body: <p>I have the following server-side code in Jersey 2.x:</p>
  
  <pre><code>@Path("/store/remove/from/group")
  @DELETE
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  @Produces(MediaType.TEXT_PLAIN)
  public Response removeStoresFromGroup(@FormParam("storeName") List&lt;String&gt; storeNames, @FormParam("groupName") String groupName) {
      //......
  }
  </code></pre>
  
  <p>On client side, I want to use Jersey 2.x client to send a delete request to the above web service. However, from the documentation of <a href="http://docs.oracle.com/javaee/7/api/javax/ws/rs/client/WebTarget.html" rel="noreferrer">Jersey client API</a>, I didn't find how to enclose the following data in DELETE request:</p>
  
  <pre><code>WebTarget webTarget = client.target("/store/remove/from/group");
  MultivaluedMap&lt;String, String&gt; formData = new MultivaluedHashMap&lt;String, String&gt;();
  List&lt;String&gt; storeName = new ArrayList&lt;String&gt;();
  storeName.add("Store1");
  storeName.add("Store2");
  storeName.add("Store3");
  
  formData.addAll("storeName", storeName);
  formData.add("groupName", "Group A");
  
  Response response = webTarget.request().accept(MediaType.TEXT_PLAIN).delete();   //The delete() method doesn't take any entity body in the request.
  </code></pre>
  
  <p>From the Jersey client API, the <a href="http://docs.oracle.com/javaee/7/api/javax/ws/rs/client/SyncInvoker.html" rel="noreferrer"><code>SyncInvoker</code></a> class doesn't support a <code>delete</code> method with entity body as its argument. So I can only use either POST or PUT to send the data to the server like the following (but not for DELETE):</p>
  
  <pre><code>Response response = webTarget.request().accept(MediaType.TEXT_PLAIN).post(Entity.form(formData)); 
  </code></pre>
  
  <p>But I want to use DELETE request since the request is deleting some resources. How to send DELETE request with some entity data via Jersey client?</p>