【发布时间】:2014-10-17 03:10:05
【问题描述】:
我正在尝试创建一个简单的 webhook 来接收来自 Nexmo SMS 服务的送达收据。他们网站上的唯一文档就是这个。
During account set-up, you will be asked to supply Nexmo a CallBack URL for Delivery Receipt to which we will send a delivery receipt for each of your SMS submissions. This will confirm whether your message reached the recipient's handset. The request parameters are sent via a GET (default) to your Callback URL and Nexmo will be expecting response 200 OK response, or it will keep retrying until the Delivery Receipt expires (up to 72 hours).
我一直在寻找执行此操作的方法,到目前为止,我从网上找到的示例中获得了此方法,尽管我不确定这是否正确。无论如何,这是在 ASP.NET 和端口 6563 上运行的,所以这是我应该监听的端口吗?我下载了一个名为 ngrok 的应用程序,它应该将我的本地 Web 服务器公开到 Internet,所以我运行该应用程序并指示它侦听端口 6563,但没有运气。我一直在摆弄它,试图找到发布到这个函数的方法。
[HttpPost]
public ActionResult CallbackURL()
{
System.IO.StreamReader reader = new System.IO.StreamReader(HttpContext.Request.InputStream);
string rawSendGridJSON = reader.ReadToEnd();
return new HttpStatusCodeResult(200);
}
一般我只要访问http://localhost:6563/Home/Index/CallbackURL就可以直接调用函数返回视图
所以我在方法签名上插入了一个断点,但只有当我从中删除 [HttpPost] 时才会调用它。我应该尝试哪些后续步骤?
【问题讨论】:
标签: c# asp.net-mvc callback http-post webhooks