SendGrid "invalid_email" DELETE api 没有删除数据
SendGrid "invalid_email" DELETE api is not deleting the data
所以我的代码看起来像这样。这是从 SendGrid 的文档中复制的。我有一个类似的删除垃圾邮件和退回邮件的功能。但是只要“Response response = sg.api(request);”这个函数就会抛出错误。被执行。请帮忙。
public boolean deleteInvalidByEmail(String email, String apiKey) throws Exception{
com.sendgrid.SendGrid sg = new SendGrid(apiKey);
Request request = new Request();
try {
if(email!=null){
request.setMethod(Method.DELETE);
request.setEndpoint("suppression/invalid_emails/"+email);
request.addQueryParam("email", email);
Response response = sg.api(request);
logger.debug(response.getStatusCode());
logger.debug(response.getBody());
logger.debug("Mapped Output =========================");
logger.debug(response.getHeaders());
}
} catch (Exception ex) {
logger.error(ex.getMessage());
ex.printStackTrace();
throw new Exception("Unable to get Delete Bounce Email Address");
}
return true;
}
从您的评论来看,您似乎遇到了 404 错误,它告诉您要删除的数据不存在。错误消息显示“找不到资源”。
因此,您尝试删除的电子邮件地址不是可删除的无效电子邮件。请注意 invalid emails are described in the docs as:
An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipient's mail server. Examples include addresses without the “@” sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server.
您要删除的电子邮件不是无效的吗?
所以我的代码看起来像这样。这是从 SendGrid 的文档中复制的。我有一个类似的删除垃圾邮件和退回邮件的功能。但是只要“Response response = sg.api(request);”这个函数就会抛出错误。被执行。请帮忙。
public boolean deleteInvalidByEmail(String email, String apiKey) throws Exception{
com.sendgrid.SendGrid sg = new SendGrid(apiKey);
Request request = new Request();
try {
if(email!=null){
request.setMethod(Method.DELETE);
request.setEndpoint("suppression/invalid_emails/"+email);
request.addQueryParam("email", email);
Response response = sg.api(request);
logger.debug(response.getStatusCode());
logger.debug(response.getBody());
logger.debug("Mapped Output =========================");
logger.debug(response.getHeaders());
}
} catch (Exception ex) {
logger.error(ex.getMessage());
ex.printStackTrace();
throw new Exception("Unable to get Delete Bounce Email Address");
}
return true;
}
从您的评论来看,您似乎遇到了 404 错误,它告诉您要删除的数据不存在。错误消息显示“找不到资源”。
因此,您尝试删除的电子邮件地址不是可删除的无效电子邮件。请注意 invalid emails are described in the docs as:
An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipient's mail server. Examples include addresses without the “@” sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server.
您要删除的电子邮件不是无效的吗?