I am trying to access the contents of an API and I need to send a URL using RestTemplate.
String url1 = \"http://api.example.com/Search?key=52ddafbe3ee659bad
You can simply append a variable key to the URL and give the value using the restTemplate.getForObject() method.
restTemplate.getForObject()
Example:
String url = "http://example.com/api?key=12345&sort={data}"; String data="{\"price\":\"desc\"}"; OutputPage page = restTemplate.getForObject(url, OutputPage.class, data);