users@jersey.java.net

Re: [Jersey] MultivaluedMap

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 28 Oct 2009 07:44:47 +0100

Hi Ronak,

What version of Jersey are you using?

I tried a quick test with 1.1.4-ea-SNAPSHOT and it worked as you
expect. There is no code to explicitly write "," in the URI builder
implementation.

BTW you can also do the following which is equivalent:

   resource.queryParam("id", "hello").queryParam("id",
"there").get(ClientResponse.class);

Are you sure you did not do:

   queryParams.add("id", Arrays.asList(new String[]{"hello", "there"}));

?

which will create query string:

   ?id=%5Bhello,+there%5D

Paul.

On Oct 28, 2009, at 3:36 AM, Ronak Patel wrote:

> Paul,
>
> I have a quite a basic question which I am embarrassed to ask but
> one I've been scratching my head about...
>
> I'm using MultivaluedMap and MultivaluedMapImpl to set my
> queryParams on the JAX-RS Jersey Client API
>
> and I don't see Jersey formulate my expected url.
>
> I am doing as so:
>
> Client client = Client.create();
> WebResource resource = client.resource("http://somehost.com/someuri");
> MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
>
> queryParams.put("id", Arrays.asList(new String[]{"hello", "there"}));
>
> resource.queryParams(queryParams).get(ClientResponse.class);
>
> Now, I don't see Jersey formulate the list of parameters as
> id=hello&id=there...and instead I see id=hello,there which is not
> what I want.
>
> What should I be doing to obtain a url with id=hello&id=there?
>
> Thanks,
>
> Ronak
>
>