Custom Webhook Receiver in .Net core 2.1

2.8k views Asked by At

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

There are 1 answers

0
sasi reka On BEST ANSWER

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 must match the data you are getting. for sender authentication, I added custom headers in Bigcommerce webhooks registration.