Webhook receiver stopped working after upgrade from .net 6 to .net 8. Below is the controller and method that was working in .net 6 anymore.
[Route("api/[controller]")]
[ApiController]
public class EController : Controller
{
[HttpPost]
[Route("/api/webhooks/incoming")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> Post(object message)
{
try
{
ResponseModel model = JsonConvert.DeserializeObject<ResponseModel>(message.ToString());
await manager.handleNotify(model);
return Ok(model);
}
catch (Exception ex)
{
Logger.Error(ex, "Failure to access incoming webhook post");
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
}
}
Packages installed: Microsoft.AspNet.WebHooks.Receivers.Custom
Microsoft.AspNet.WebHooks.Receivers.Generic
Program.cs
var config = new HttpConfiguration();
config.InitializeReceiveGenericJsonWebHooks();
config.InitializeReceiveCustomWebHooks();