I am trying to get a JSON Object from an API while using an API key in the header. This works perfectly when I test it in Postman, but when I try it in my Spring application.
I got an error:
There was an unexpected error (type=Not Found, status=404). No message available.
API-Key and the URL
are changed out with dummy data
@RequestMapping(value = "/apitest", method = RequestMethod.GET, headers ="APIKey=12345")
public @ResponseBody void testingAPI() throws ParseException {
final RestTemplate restTemplate = new RestTemplate();
final String response = restTemplate.getForObject("url", String.class);
System.out.println(response);
}