Skip to content

Instantly share code, notes, and snippets.

@jcarlosgarcia
Created July 4, 2012 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcarlosgarcia/3047906 to your computer and use it in GitHub Desktop.
Save jcarlosgarcia/3047906 to your computer and use it in GitHub Desktop.
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