我希望有人可以提供帮助。我有一个通过Azure运行的ASP.NET MVC网站。这里的最终目标是将SendGrid事件记录到数据库中。首先,我需要获取SendGrid发送的JSON。我已在Settings--> Mail Settings--> Event Notification
下启用了“事件通知”。在Azure和Azure远程调试中使用Postman和Streaming Log,我确定我的控制器确实从SendGrid接收POST请求,但是我没有得到任何JSON。
我尝试过以下方法:
在下面的示例中,json为null:
public ActionResult SendGridOne(string json)
在下面的示例中,eventList为null(注意这是使用Sendgrid.Webhooks nuget包):
public ActionResult SendGridOne([FromBody]SendGridEvents[] eventList)
还试过以下内容,但rawSendGridJSON始终为null:
public ActionResult SendGridOne()
{
System.IO.StreamReader reader = new System.IO.StreamReader(HttpContext.Request.InputStream);
string rawSendGridJSON = reader.ReadToEnd();
System.Diagnostics.Trace.TraceInformation(rawSendGridJSON);
return new HttpStatusCodeResult(200);
}
答案 0 :(得分:0)