答案 0 :(得分:1)
我认为您应该在请求中添加“ User-Agent”标头。您可以尝试设置自定义用户代理值,也可以使用一些标识浏览器的值。
像-
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
headers.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");
HttpEntity<String> entity = new HttpEntity<String>("parameters", headers);
Object response = restTemplate.exchange("https://test.prateek.com/tests.json", HttpMethod.GET,entity,Object.class);