users@jersey.java.net

how to post objects using Jersey Client ?

From: Felipe Gaúcho <fgaucho_at_gmail.com>
Date: Sun, 9 Aug 2009 16:07:32 +0200

I am looking for an example of posting objects to my jersey ws:

example:

        @POST
        @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
        @Path("create")
        public PujUserEntity create(PujUserEntity user) {
                return userFacade.create(user);
        }

so, how do I call this resource using Jersey Client ?

in the samples I found something like this:

            ClientResponse response = service.
              path("contacts").
              path(username).
              type(ENTRY_MEDIA_TYPE).
              header(AUTHENTICATION_HEADER, authentication).
              post(ClientResponse.class, contact.asEntry());
            return response.getLocation().toString();