且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

.Net Core 2.1中的自定义Webhook接收器

更新时间:2022-12-27 11:13:29

我能够在不使用webhook处理程序或接收器的情况下接收数据.我刚刚通过从请求主体获取数据在控制器中创建了一个"POST"方法.

I was able to receive the data, without using webhook handler or receiver. I just created a "POST" method in my controller by getting data from request body.

[HttpPost("customer_update")]
public void GetCustomerUpdateHook([FromBody] WebhookResponse p_data)
{
    d_logger.Information("Process Webhook reply Web Response Hit"); 
    var dataAsString = Newtonsoft.Json.JsonConvert.SerializeObject(p_data);
    d_logger.Information("Response ==> {@data}", dataAsString);           
}

但是 WebhookResponse 类必须与您获取的数据匹配.为了进行发件人身份验证,我在Bigcommerce webhooks注册中添加了自定义标头.

But WebhookResponse class must match the data you are getting. for sender authentication, I added custom headers in Bigcommerce webhooks registration.