I am trying to consume a web page service with RestTemplate
of Spring
. However I get the error 403, but if I consume the URL from PostMan then it does bring me the information without error. Does anyone know how I can solve this problem? I leave the code of the method I use to consume the URL:
RestTemplate rt = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
headers.set("Accept", MediaType.TEXT_HTML_VALUE);
HttpEntity<?> entity = new HttpEntity<>(headers);
HttpEntity<String> response = rt.exchange(URLRest, HttpMethod.GET, entity, String.class);
return response.getBody();