You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Patrick Lightbody <pa...@lightbody.net> on 2011/09/07 00:31:33 UTC

Building up GET query params dynamically

I need to build up some GET query parameters dynamically (it's for an API wrapper). Is there some nice helper API that can let me just specify the parameters as simple name/value pairs and it'll turn it in to a nice query parameter string?

In 3.x there was method.setQueryString()[1] but I can't find an equivalent.

Thanks!

Patrick

[1] http://stackoverflow.com/questions/217070/how-do-i-add-query-parameters-to-a-getmethod-using-java-commons-httpclient





Re: Building up GET query params dynamically

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2011-09-07 at 11:59 -0400, Bill Speirs wrote:
> The static method format in the URLEncodedUtils should be able to help
> you with this: http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/utils/URLEncodedUtils.html#format(java.util.List,
> java.lang.String)
> 

There will be UriBuilder included in the next feature release (4.2). For
the time being you could use a local copy of the class:

http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/UriBuilder.java

Oleg 

> Bill-
> 
> On Tue, Sep 6, 2011 at 6:31 PM, Patrick Lightbody <pa...@lightbody.net> wrote:
> > I need to build up some GET query parameters dynamically (it's for an API wrapper). Is there some nice helper API that can let me just specify the parameters as simple name/value pairs and it'll turn it in to a nice query parameter string?
> >
> > In 3.x there was method.setQueryString()[1] but I can't find an equivalent.
> >
> > Thanks!
> >
> > Patrick
> >
> > [1] http://stackoverflow.com/questions/217070/how-do-i-add-query-parameters-to-a-getmethod-using-java-commons-httpclient
> >
> >
> >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: Building up GET query params dynamically

Posted by Bill Speirs <bi...@gmail.com>.
The static method format in the URLEncodedUtils should be able to help
you with this: http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/utils/URLEncodedUtils.html#format(java.util.List,
java.lang.String)

Bill-

On Tue, Sep 6, 2011 at 6:31 PM, Patrick Lightbody <pa...@lightbody.net> wrote:
> I need to build up some GET query parameters dynamically (it's for an API wrapper). Is there some nice helper API that can let me just specify the parameters as simple name/value pairs and it'll turn it in to a nice query parameter string?
>
> In 3.x there was method.setQueryString()[1] but I can't find an equivalent.
>
> Thanks!
>
> Patrick
>
> [1] http://stackoverflow.com/questions/217070/how-do-i-add-query-parameters-to-a-getmethod-using-java-commons-httpclient
>
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org