Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Sending a POST request to a REST service using Jersey Client
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment