本文介绍了如何接收来自 Zoho Sign Webhook 的响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am able to hit my call back function from Zoho Sign webhook. But I am not able to figure out how can I receive the response that Zoho Sign sends to my callback URL. Their documentation: https://www.zoho.com/sign/api/#webhook-management

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

Below is my sample code that I am using to confirm that callback function is hit. It saves a sample data to DB to confirm it is being hit. But the response I am not being able to catch hold of. This is their help documentation that guides on the same, but that misses a working sample. 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 团队的大量跟进和通话,我好几天都没有得到他们的任何帮助.

Finally, after a lot of hits and trials, this code worked for me. It's bad that after a lot of follow-up and calls with the Zoho team, I did not receive any help from them for many days.

[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;
}

这篇关于如何接收来自 Zoho Sign Webhook 的响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 02:08