I keep getting the below exception when I try to do a GET
request. A direct curl request to the url works fine but this doesn't. I'm trying to call service on port 8085
from the service on port 8082
.
Code
ResponseEntity<List<String>> quoteResponse = restTemplate.exchange("http://localhost:8085/rest/test/{username}", HttpMethod.GET,
null, new ParameterizedTypeReference<List<String>>() {
},userName);
Curl
curl 'http://localhost:8082/rest/test/user1' -H "Content-Type: application/json"
Error
org.springframework.web.client.HttpClientErrorException$NotFound: 404 : [<Map><timestamp>2020-06-18T23:35:31.449+00:00</timestamp><status>404</status><error>Not Found</error><message></message><path>/rest/test/user1</path></Map>]
at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:113) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:184) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:125) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63) ~[spring-web-5.2.7.RELEASE.jar:5.2.7.RELEASE]