0

我开发了一个 webhook 接收器来读取邮件中发送的自定义值并将该值保存在数据库中。当我在邮递员上对此进行测试时,它正在将值保存在数据库中。但是当我在 hasura 中对此进行测试时,它显示了一个错误,例如“发生错误”。我无法弄清楚我错过了什么。以下是我的代码。

通用Webhook.cs

public class GenericWebhook: WebHookHandler

{
    public GenericWebhook()
    {
        this.Receiver = "genericjson";
    }

    public override Task ExecuteAsync(string receiver, WebHookHandlerContext context)
    {
        try
        {
           // context = "";

            JObject data = context.GetDataOrDefault<JObject>();
           dynamic response = JsonConvert.DeserializeObject(data.ToString());

                List<ReturnResultBL> ResultList = response.Payload.ToObject<List<ReturnResultBL>>();

                WebhookLocal webhookObj = new WebhookLocal();

                string varResult = webhookObj.SaveMailDetails(ResultList);

           return Task.FromResult(false);
        }
        catch (Exception ex)
        {
            throw;
        }

    }

WebhookLocal.cs ----

public class WebhookLocal
{
    internal string SaveMailDetails(List<ReturnResultBL> resultList)
    {
        try
        {
 SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TPAConnection"].ConnectionString);
            con.Open();

            string query = "insert into tblMailData(col1,col2,..)values('col1','col2');
 SqlCommand cmd = new SqlCommand(query, con);
 int rVal = cmd.ExecuteNonQuery();
            con.Close();
 }
        catch (Exception ex)
        {
          throw;
        }

        return "true";


    }
4

0 回答 0