我使用dropwizard和jersey2休息客户端,我得到了
javax.ws.rs.BadRequestException: HTTP 400 Bad Request
然而,当我打开日志记录时,我看到了
DEBUG [2016-04-25 05:17:10,196] org.apache.http.wire:
http-outgoing-0 << "{"apiVersion":"v1","timestamp":"April 24, 2016,
10:17 pm","error":{"asiErrorCode":"12002","message":"A
message","moreInfo":"http:\/\/bar.foo.net"}}" INFO [2016-04-25
05:17:10,197] unknown.jul.logger: 1 * Client response received on
thread main 1 < 400 1 < Access-Control-Allow-Headers: Accept,
Content-Type, Authorization 1 < Access-Control-Allow-Methods: GET,
POST, PUT, DELETE 1 < Access-Control-Allow-Origin: * 1 < Allow:
OPTIONS,GET,POST,PUT,DELETE 1 < Cache-Control: no-cache, no-store,
must-revalidate 1 < Connection: close 1 < Content-Length: 265 1 <
Content-Type: application/json 1 < Date: Mon, 25 Apr 2016 05:17:10
GMT 1 < Expires: 0 1 < Pragma: no-cache 1 < Server: Apache/2.4.12
(Win32) OpenSSL/1.0.1m mod_jk/1.2.40 PHP/5.6.14
{"apiVersion":"v1","timestamp":"April 24, 2016, 10:17
pm","error":{"asiErrorCode":"12002","message":"A
message","moreInfo":"http:\/\/foo.bar.net"}}
如何反序列化此响应而不是仅获得400?
我的代码看起来像
return client.target(URL).get(AsiAccounts.class);
AsiAccounts基本上是空的
@JsonIgnoreProperties
public class AsiAccounts
}
我向AsiAccounts添加了apiVerson,时间戳和错误,但它仍然无法正常工作。任何帮助表示赞赏。
答案 0 :(得分:-1)
你可以这样使用
Response.status(200).entity(asiAccount).build();