我正在尝试使用邮件枪API获取反弹邮件数据。Java客户端消费API
public static ClientResponse GetBounce() {
Client client = new Client();
client.addFilter(new HTTPBasicAuthFilter("api",
"key-XXXXXXXXXXXXXXXXXXXXX"));
WebResource webResource =
client.resource("https://api.mailgun.net/v3/XXXXXXXXXXXX.mailgun.org/" +
"bounces/[email protected]");
return webResource.get(ClientResponse.class);}
它正常工作的API调用就可以了,但我不能ClientResponse转换成合适的类型在我的CAE EmailError。从服务器 实际响应{"address":"[email protected]","code":"550","error":"550 5.2.1 The email account that you tried to reach is disabled. lq5si9613879igb.63 - gsmtp","created_at":"Tue, 18 Aug 2015 12:23:35 UTC"}
我创建POJO映射响应
@JsonAutoDetect(getterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
@JsonSerialize(include = Inclusion.NON_NULL)
public class EmailError {
private String address;
private String error;
private String created_at;
//geters...
//setters..
}
并尝试ClientResponse映射到EmailError类型。
ClientResponse clientResponse = getBounce(email);
EmailError error = response.getEntity(new GenericType<EmailError>() {
});
其中clientResponse是方法GetBounce()
It throws an Exception com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class com.che.rt.businessservices.EmailError, and Java type class com.che.rt.businessservices.EmailError, and MIME media type application/json;charset=utf-8 was not found
任何猜测我很想念那里的对象的回报。
显示您的依赖。 –