0
I’m getting an error, possibly from CORS, when making a GET for an API, which is a third-party API and I don’t have how to release server-side CORS:
Exception in thread "main" org.springframework.web.client.Resourceaccessexception: I/O error on GET request for "https://api.cartolafc.globo.com/time/id/17886329/1": Unexpected end of file from server; nested Exception is java.net.Socketexception: Unexpected end of file from server
I am consuming an API using Resttemplate as follows:
public class FamiliabomdebolaApplication {
public static void main(String[] args) {
SpringApplication.run(FamiliabomdebolaApplication.class, args);
RestTemplate template = new RestTemplate();
UriComponents uri = UriComponentsBuilder.newInstance().scheme("https").host("api.cartolafc.globo.com")
.path("time/id/17886329/1")
// .queryParam("fields", "all")
.build();
ResponseEntity<Time> entity = template.getForEntity(uri.toUriString(), Time.class);
System.out.println(entity.getBody().getEsquema_id());
}
}
Can anyone help me? I’ve heard something about using proxy, but I don’t know how to implement it in Java/Spring
Perfect, Emerson. Thank you very much!
– Adriano Valentim