users@jersey.java.net

Jersey Client usage for POSTing to REST endpoints

From: Arul Dhesiaseelan <arul_at_fluxcorp.com>
Date: Mon, 18 Aug 2008 11:07:50 -0600

Hello,

I recently wrote a blog entry
(http://aruld.info/yahoo-search-restful-client-using-jersey/) on using
Jersey Client for invoking Yahoo Search APIs.

Is there a better way to construct query params on the client side when
doing a POST using Jersey Client? I am not sure if my current approach
shown below is correct. But it works.

Context params can be sometimes lengthy, and the below construction may
look ugly in that case.

WebResource
r = client.resource("http://search.yahooapis.com/WebSearchService/V1/contextSearch");

ResultSet
searchResults = r.accept(MediaType.APPLICATION_XML).post(ResultSet.class, "appid=YahooDemo&query=madonna&context=Italian+sculptors+and+painters+of+the+renaissance+favored+the+Virgin+Mary+for+inspiration");


Appreciate any suggestions.

-Arul