grails-plugins / grails-rest-client-builder

REST client plugin that uses Spring's RestTemplate
http://grails.org/plugin/rest-client-builder
Apache License 2.0
65 stars 32 forks source link

post params containing '#' are not urlencoded #28

Open mscottpriddy opened 10 years ago

mscottpriddy commented 10 years ago

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

sdelamo commented 8 years ago

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