I\'ve written a simple ASP.NET Core 2.2 Web API
. The POST
method always returns a 404
, but GET requests succeed.
public cl
You have not specified a route to the action. You can either change your post to go to /api/Test or set the attributes on the action as follows:
[HttpPost("Create")]
public async Task<ActionResult<string>> Create([FromBody] TestPayload value)
{
return Ok("");
}
or
[HttpPost]
[Route("Create")]
public async Task<ActionResult<string>> Create([FromBody] TestPayload value)
{
return Ok("");
}
or update the controller route to include the action
[Route("api/[controller]/[action]")]
Try to add:
[EnableCors(origins: " * ", headers: " * ", methods: " * ")]
to your Controller class. ( remove with spaces in the quotes )
More info on Microsoft-Website