如何接收来自 Zoho Sign Webhook 的响应

问题描述

我可以从 Zoho Sign webhook 中调用我的回调函数。但我无法弄清楚如何接收 Zoho Sign 发送到我的回调 URL 的响应。他们的文档:https://www.zoho.com/sign/api/#webhook-management

下面是我用来确认回调函数被命中的示例代码。它将样本数据保存到 DB 以确认它正在被命中。但我无法抓住的回应。这是他们的帮助文档,指导相同,但缺少工作示例。 https://help.zoho.com/portal/en/community/topic/webhooks-for-zoho-sign

[HttpPost]
        public ActionResult Callback()
        {
            using (var context = new ZohoApiTestEntities())
            {
                var rowDetails = new tblWebhook();
                rowDetails.PhoneNo = "7978704767";
                //rowDetails.Notes1 = jsonObj.ToString();
                context.tblWebhooks.Add(rowDetails);
                context.SaveChanges();
            }
            return new HttpStatusCodeResult(HttpStatusCode.OK);
        }

解决方法

最后,经过大量的尝试和试验,这段代码对我有用。很遗憾,经过与 Zoho 团队的大量跟进和通话,我好几天都没有得到他们的任何帮助。

[HttpPost]
public ActionResult Callback()
{
    string rawBody = GetDocumentContents(Request);
    dynamic eventObj = JsonConvert.DeserializeObject(rawBody);
    using (var context = new ZohoApiTestEntities())
    {
        var rowDetails = new tblWebhook();
        rowDetails.PhoneNo = "*********";
        //eventObj comes in JSOn format with two keys,"requests" and "notifications" each containing a JSON object https://www.zoho.com/sign/api/#webhook-management
        //you can get your required details like this
        string recipientName = eventObj.notifications.performed_by_name.ToString();
        rowDetails.Notes1 = recipientName;
        context.tblWebhooks.Add(rowDetails);
        context.SaveChanges();
    }
    return new HttpStatusCodeResult(HttpStatusCode.OK);
}

private string GetDocumentContents(HttpRequestBase Request)
{
    string documentContents;
    using (Stream receiveStream = Request.InputStream)
    {
        using (StreamReader readStream = new StreamReader(receiveStream,Encoding.UTF8))
        {
            documentContents = readStream.ReadToEnd();
        }
    }
    return documentContents;
}