It just so happens that the RestTemplate#getForObject(..)
method that expects a String
builds a URI from the given String
and encodes it before using it. It uses custom Spring classes to do this. (See the source code.)
You can fix this issue by creating a URI
object from your String
and pass that to the method.
String url = uriBuilder.build().toString(); // this is right url
URI uri = new URI(url);
MyEntity result = restTemplate.getForObject(uri, MyEntity.class);