I'm doing an api with an upload file using multipart/form-data, Unfortunately when I'm trying to use an xlsx file or other certain files, it always returns an 422 unprocessable entity.
Is there some sort of configuration to enable the uploading of other files?
Code below :
[Route("api/test")]
[ApiController]
public class TestController : ControllerBase
{
public TestController()
{
}
[AllowAnonymous]
[HttpPost("import")]
public ActionResult ImportFile([FromForm] IFormFile file)
{
try
{
using (Stream strm = file.OpenReadStream())
{
return Ok($"File uploaded had {file?.Length ?? -1} bytes");
}
}
catch (Exception ex)
{
return BadRequest(ex);
}
}
}

