In the previous example, both variable name and the parameter name are the same. Like Spring JdbcTemplate , RestTemplate is also a high-level API, which in turn is based on an HTTP client. The following GET request is made with query parameters and request headers: Sometimes we want these to be different, though. I was kinda hoping there would be a nicer way to populate my query parameters rather than an ugly concatenated String but there we are. {foobar}, this will cause an exception. In here, the HTTP GET request is made with query parameters (request parameters) and Basic Authentication header. Or, if we aren't using Spring Boot, we may need to do special compile-time configuration or the parameter names won't actually be in the bytecode.

If query parameter contains parenthesis, e.g. With this information in mind I cannot find a way to use the UriComponentsBuilder to send a request to the server, that preserves the + in the query string after it was decoded by tomcats parsing logic. Spring RestTemplate – exchange() method with GET and POST Requests . The safe way is to expand the path variables first, and then add the query parameters: for example: @RequestParam(value = "phone", required = false) List phones or @RequestParam(value = "phone", required = false) Set phones The RestTemplate is the central class within the Spring framework for executing synchronous HTTP requests on the client side. Learn To Make REST calls With RestTemplate In Spring Boot Posted By : S. Ajit | 09-Apr-2017 According to wikipedia, Representational state transfer (REST) or RESTful Web services are one way of providing interoperability between computer systems on the Internet. GET Request with Parameters and Headers. To add custom request headers to HTTP GET request, you should use the generic exchange() method provided by the RestTemplate class. Maybe you have an idea how one can send a + sign as query parameter to the server. It’s simply a case of build the URL with the correct parameters. OK, so I’m being an idiot and I’m confusing query parameters with url parameters. This was possible with version 4 of spring. Spring can convert the query param directly into a List or even a Set. An issue with the answer from Michal Foksa is that it adds the query parameters first, and then expands the path variables.