I have a method that consumes a WS to send a mail. If the email account is real it works fine, but if the email account is not real it returns a 500 error through the getResponseCode. The bad thing is that additional it shows me a window with the indicated error.
Before running it make sure to run the following method:
ConnectionRequest.setHandleErrorCodesInGlobalErrorHandler(false);
My Method:
public static Response imprimePedido(Long pedidoId) {
String serverPost = "";
Response<String> r = null;
if (Preferences.get("correo_prueba", null) != null) {
serverPost = SERVER_URL + "blank_factura_impresion_pdf/blank_factura_impresion_pdf.php?pedidoId=" + Long.toString(pedidoId) + "&correo_prueba=" + Preferences.get("correo_prueba", null);
} else {
serverPost = SERVER_URL + "blank_factura_impresion_pdf/blank_factura_impresion_pdf.php?pedidoId=" + Long.toString(pedidoId);
}
try {
r = Rest.post(serverPost).
header("token", UsuarioService.getToken()).
jsonContent().getAsString();
if (r.getResponseCode() != 200) {
System.out.println("No pude enviar correo");
log("Error: " + r.getResponseErrorMessage());
}
} catch (Exception e) {
e.printStackTrace();
}
return r;
}
