GET 请求包含类似于以下内容的 JSON 有效负载: { "customeId" : "A123", "Status" : "Assigned", "StartDate" : "2020-07-18", "EndDate" : "2020-07-20 ", "FetchLimit" : "10" } 我正在使用多值映射来添加这些输入以及标题(内容类型、接受、相关 ID)。相同的请求有效负载通过 Postman 提供响应,但是当我使用 RestTemplate.exchange(URL, HttpMethod.Get ,entity, Response.class) 进行 GET 调用时,收到的响应为 308 PERMANENT REDIRECT。对解决方案的任何想法都会很棒!TIA ###下面的代码片段####
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("Accept",MediaType.APPLICATION_JSON_VALUE);
headers.set("Correlation-ID","1234");
MultiValueMap<String, String> map= new LinkedMultiValueMap<String, String>();
map.add("customerId","A123");
map.add("status","Assigned");
map.add("StartDate","2020-07-18");
map.add("EndDate","2020-07-19");
map.add("FetchLimit","10");
String urlString = "http://dev-editest.com/cust/v1/retreiveById"
HttpEntity<?> request = new HttpEntity<>(map, headers);
ResponseEntity<User> response = restTemplate.exchange(urlString, HttpMethod.GET, request, User.class);