I am trying to use reverse geocoding using the following end point: https://api.tomtom.com/search/2/reverseGeocode/crossStreet/37.8328%2C-122.27669.json?key=<api_key>. Although this works when passed in browser but shows the following error when I make restTemplate call using spring boot:
org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request: [{"errorText":"Invalid request: invalid position: cannot parse position.","detailedError":{"code":"BadRequest","message":"Invalid request: invalid position: cannot parse position."},"httpStatusCode":400}]
This is the piece of code I am using:
@GetMapping("/revgeocode/data")
public Addresscontainer reverseGeoCode(@RequestParam String position)
{
Addresscontainer res = restTemplate.getForObject("https://api.tomtom.com/search/2/reverseGeocode/crossStreet/37.8328%2C-122.27669.json?key="+ apiKey, Addresscontainer.class);
return res;
}`
I am just a beginner. Please help.
Thanks in advance.