Custom Webhook Receiver in .Net core 2.1

2019-07-24 08:12发布

问题:

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");            
}

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.

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

回答1:

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

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