本文介绍了.Net Core 2.1中的自定义Webhook接收器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为bigcommerce webhooks创建webhooks接收器.

I'm trying to create webhooks receiver for bigcommerce webhooks.

[HttpPost("customer_update")]
public void GetCustomerUpdateHook()
{
    d_logger.Information("Process Webhook reply Web Response Hit");
}

我的功能正常运行,没有任何问题.但是我不知道如何访问接收数据.我不确定如何使用WebHookHandler.

my function is getting hit without any issues. But I don't know how to access the receiving data. I'm not sure how to use WebHookHandler.

框架=> .Net核心2.1controller => API控制器

framework => .Net core 2.1controller => API Controller

推荐答案

我能够在不使用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.

这篇关于.Net Core 2.1中的自定义Webhook接收器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 14:03