Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从外部响应获取未编码的消息_Java_Spring Boot_Spring Cloud Feign_Feign - Fatal编程技术网

Java 从外部响应获取未编码的消息

Java 从外部响应获取未编码的消息,java,spring-boot,spring-cloud-feign,feign,Java,Spring Boot,Spring Cloud Feign,Feign,我有一个POST方法,成功时返回JSON响应,错误时返回application/x-www-form-urlencoded @PostMapping(path = SUBSCRIBE_PATH, consumes = APPLICATION_JSON_VALUE) MySubscribeRs subscribe(@RequestHeader("Api-Key") String apiKey, @Reque

我有一个POST方法,成功时返回
JSON
响应,错误时返回
application/x-www-form-urlencoded

@PostMapping(path = SUBSCRIBE_PATH, consumes = APPLICATION_JSON_VALUE)
    MySubscribeRs subscribe(@RequestHeader("Api-Key") String apiKey,
                                @RequestBody String requestBody);
下面是一个错误示例:

400 Bad request
["The user already has a subscription"]
我捕获了FaignException,其中包含详细信息:

[400 Bad Request] during [POST] to [http://localhost:11619/api/cb/payments/subscribe/] [MyFeignRestClient#subscribe(String,String)]: [["The user already has a subscription"]]

如何在不解析字符串的情况下获取
“用户已经有订阅”
消息?

如果REST调用没有返回JSON响应,而是返回异常消息,则需要解析异常消息。exception.getMessage()返回什么?@SusanMustafa我在帖子中描述了它,您需要解析它