Monday, April 12, 2010

How to properly encode "[" and "]" in queries using Apache HttpClient?

Programmer Question

I've got a GET method that looks like the following:



 GetMethod method = new GetMethod("http://host/path/?key=[\"item\",\"item\"]");


Such a path works just fine when typed directly into a browser, but the above line when run causes an IllegalArgumentException : Invalid URI.



I've looked at using the URIUtils class, but without success. Is there a way to automatically encode this (or to add a query string onto the URL without causing HttpClient to barf?).



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails