Shankar Shankar - 1 month ago 5x
reST (reStructuredText) Question

Spring Restful service - replace queryString with dynamic values

I am trying to consume restful web service using RestTemplate class.

Sample code:

String quote = restTemplate.getForObject("", String.class);;

In this queryString i want to dynamically pass
. How do i do that?


Any url variable can be wrapped in {} and passed in as a variable. If you have more than one it's replace them in order.

If you need a more complicated logic use UriComponentsBuilder to build your url.

String quote = restTemplate.getForObject("{dynamic-param}?&fmt=json&inc=url-rels+release-groups", String.class, "f27ec8db-af05-4f36-916e-3d57f91ecf5e");