I developed a webhook receiver to read custom values sent in the mail and save that values in the database. When I tested this on the postman, it is saving values in the database. but when I tested this in hasura, it shows an error like ' an error has occurred '. I am unable to figure out what I am missing. Following is my code.
GenericWebhook.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";
}
>();