Custom Webhook Receiver in .Net core 2.1

不打扰是莪最后的温柔 提交于 2020-01-05 06:14:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!