I am Creating a REST API in java and testing it in postman and in the database have the latitude and longitude, I am trying to use the OpenWeather API to return weather data based on the latitude and longitude. however, when testing it in postman it is returning an HTML and not the JSON data I requested.
the path I am trying to test is
http://localhost:8080/Assignment2C/map/weather/4
the code in my controller is
@GetMapping(value = "weather/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public String getWeather(@PathVariable("id") int id) {
BreweriesGeocode geocode = geocode_service.getGeocode(id);
Breweries brewerie = breweries_service.getBrewerieById(id);
double latitude = geocode.getLatitude();
double longitude = geocode.getLongitude();
String output = "https://api.openweathermap.org/data/2.5/weather?lat=" + latitude + "&lon=" + longitude + "&appid=4a1f5501b2798f409961c62d384a1c74";
return output;
when using Postman it returns this
https: //api.openweathermap.org/data/2.5/weather?lat=59.74509811401367&lon=10.213500022888184&appid=4a1f5501b2798f409961c62d384a1c74
but when I test the path that postman produces in the browser
https://api.openweathermap.org/data/2.5/weather?lat=59.74509811401367&lon=10.213500022888184&appid=4a1f5501b2798f409961c62d384a1c74
it returns the correct JSON data
which is
{"coord":{"lon":10.21,"lat":59.75},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"base":"stations","main":{"temp":291.36,"feels_like":289.49,"temp_min":288.71,"temp_max":294.26,"pressure":1028,"humidity":40},"wind":{"speed":0.89,"deg":190},"clouds":{"all":1},"dt":1587551663,"sys":{"type":3,"id":2006615,"country":"NO","sunrise":1587526916,"sunset":1587581574},"timezone":7200,"id":6453372,"name":"Drammen","cod":200}
how do I get the JSON data to appear in postman when I test it?
