grails-plugins/grails-rest-client-builder

post params containing '#' are not urlencoded

Opened this issue · 1 comments

Everything after the '#' is truncated when submitting a rest.post(url, params map).

I tried to find an alternate strategy for passing query parameters, but could not find an approach that would properly url encode a '#' value.

To reproduce,

def url = "http://someServer/foo/bar"
def requestParams = [username:"someDude", password:"abc#123"]
def restClient = new RestBuilder()
def response = restClient.post(url,requestParams)

The final url that is used on the post is:
http://someServer/foo/bar?username=someDude&password=abc

I don't think this is an issue. The problem is the way to pass url params.

def url = 'http://someServer/foo/bar?username={username}&password={password}'
def requestParams = [username:"someDude", password:"abc#123"]
def restClient = new RestBuilder()
def response = restClient.post(url, requestParams)

Please note the above url is not a GString with string interpolation but a String that uses the format/convention specified in the RestTemplate javadoc.

http://docs.spring.io/spring/docs/3.2.x/javadoc-api/org/springframework/web/client/RestTemplate.html