我正在尝试发送。
在我的Spring Boot应用程序中,我遇到了以下异常:
headers.add("Accept-Encoding", "gzip");
在我的Spring Boot应用程序中,我遇到了以下异常:
com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
但我需要将gzip作为请求头发送。
我的Spring Boot版本是“1.3.5.RELEASE”。
请帮我解决问题。
我的请求示例:
url = apiUrl + apiMethod + "?api_key=" + apiKey;
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.add("api_key", apiKey);
headers.add("Content-Type", "application/json");
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
headers.set("Accept-Encoding", "x-gzip");
HttpEntity < String > entity = new HttpEntity < String > ("parameters", headers);
ResponseEntity < GenericResponseDto > response = null;
try {
response = restTemplate.exchange(url, HttpMethod.GET, entity,
GenericResponseDto.class);
log.info("Response :" + response.toString());
} catch (Exception e) {
throw new CustomException(e, aPIAuditTrail);
}