【发布时间】:2019-05-17 13:32:47
【问题描述】:
如何在 Spring boot 中实现 sendgrid 解析 API。
代码:
@RequestMapping(value = "/api/sendGridParse",method = RequestMethod.POST)
public ResponseEntity<APIResponseDTO> sendGridParseDoamin(@ModelAttribute EmailParseDTO emailParseDTO )
{
APIResponseDTO _response = new APIResponseDTO();
System.out.println("emailParseDTO:"+emailParseDTO.toString());
try{
_response.setMessage("Success");
_response.setStatus(100);
}catch (Exception e) {
e.printStackTrace();
_response.setMessage("Failed");
_response.setStatus(101);
}
return new ResponseEntity<APIResponseDTO>(_response, HttpStatus.OK);
}
EmailParseDTO:
public class EmailParseDTO {
int attachments;
String charsets;
String from;
String headers;
String html;
String subject;
String envelope;
String text;
String to;
String cc;
//setter and getter
但它不会将解析后的数据发送到上面的 url。
【问题讨论】:
-
您发布的问题与手头的问题不匹配。代码中没有提到给定的 url。请使用相关代码发布您尝试过的内容。
-
感谢 Sangam 的回复。我需要代码 sn-p 用于在 Spring boot 中发送网格解析器 API。就像每当向特定域发送任何邮件时一样。 abc.com.
-
Sendgrid 没有将解析后的数据发送到上面的 API。这是我在发送网格中配置的 URl (d3a26271.ngrok.io/api/sendGridParse)。我的 API 代码有什么问题吗?
-
您需要在您的 application.properties 中添加您的相关密钥和 sendgrid 提供的其他详细信息。然后它应该将请求发送到 sendGrid 服务器。发送请求时您会得到什么响应?
标签: java spring-boot sendgrid