Spring resttemplate InvalidMediaTypeException。由于令牌中的无效令牌字符“@”而导致无效的 MIME 类型

时间:2021-03-10 22:56:33

标签: spring http resttemplate

我正在调用的 api 使用值中包含 @ 的内容类型响应我的 resttemplate 调用。

        final HttpHeaders headers = new HttpHeaders();
        headers.set(HttpHeaders.ACCEPT, "key=abcd@def");
        final ResponseEntity<String> responseEntity = resttemplate.exchange(
                path, HttpMethod.GET, new HttpEntity<>(null, headers),
                String.class);

Response Header
content-type: key=abc@def

我得到的错误

org.springframework.http.InvalidMediaTypeException: 
Invalid mime type "key=abcd@def": Invalid token character '@' in token "abcd@def"

0 个答案:

没有答案
相关问题