I've created a new controller in my .NET Core MVC rest service and it's not routing to the POST function when I call the API.
I've got existing controllers that are in the exact same format as this one, I can't determine why the service function is not getting called. The request is always returning a generic 500 error.
URL: https://address:port/api/TOSResponse
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using MyProject.ActionFilters;
using MyProject.Common.Exceptions;
using MyProject.Services;
namespace MyProject.Controllers
{
[ServiceFilter(typeof(KeyValidatorFilter))]
[Route("api/[controller]")]
public class TOSResponseController : Controller
{
private ITOSResponseService _tosResponseService;
public TOSResponseController(ITOSResponseService tosResponseService)
{
_tosResponseService = tosResponseService;
}
[HttpPost]
public IActionResult Post([FromBody] List<Models.TermsOfServiceResponse> tosResponses)
{
try
{
_tosResponseService.InsertOrUpdate(tosResponses);
return new OkResult();
}
catch (PLException ex)
{
return new BadRequestObjectResult(ex.ErrorValue);
}
}
}
}