问题
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 must match the data you are getting. for sender authentication, I added custom headers in Bigcommerce webhooks registration.
来源:https://stackoverflow.com/questions/52516378/custom-webhook-receiver-in-net-core-2-1