Spring RestTemplate交换返回204和邮递员200

时间:2019-01-09 16:10:35

标签: spring web-services postman spring-rest

从今天早上开始,我就转过身来,我有这种方法可以在Java中返回NO_CONTENT(204),但是当我在邮递员中执行相同的URL时,我得到了Content(200)

String encodedCredentials = getEncodedCredentials(deviceConfigurationInstance);

RestTemplate restTemplate = getRestTemplate(url, deviceConfigurationInstance);

HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic " + encodedCredentials);
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Accept", "*/*"); 
HttpEntity<String> request = new HttpEntity<String>(headers);

ResponseEntity<T> response = restTemplate.exchange(url, HttpMethod.GET, request, retType);

return response;

我也在邮递员中添加了凭证

我在Java中忘记了什么?

注意:retType的类型为Class<T>

0 个答案:

没有答案