public
Created

Sending a POST request to a REST service using Jersey Client

  • Download Gist
post_jersey_client.java
Java
1 2 3 4 5 6 7 8 9
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource service = client.resource(getBaseURI());
 
MultivaluedMap<String, String> formData = new MultivaluedMapImpl();
formData.add("parameter1", "value1");
formData.add("parameter2", "value2");
 
ClientResponse response = service.path("resource").accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, formData);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.