我使用ASP.NET Core使用以下代码控制器 -
namespace WebApplication.Controllers
{
[Route("api/[controller]")]
public class TodoController : ControllerBase
{
[HttpPost]
public List<Testing> Create([FromBody] List<Testing> item)
{
return item;
}
}
}
当我尝试使用fiddler -
执行以下HTTP发布时POST - http://localhost:30001/api/todo
Content-Type: application/json; charset=utf-8
Host: localhost:30001
Content-Length: 117
[{"Name":"Item1","LastName":"Test1"}, {"Name":"Item2","LastName":"Test2"}, {"Name":"Item3","LastName":"Test3"}]
我最终得到了415 Unsupported Media Type异常。如果我从POST请求中的参数中删除[FromBody]属性为null。如何修复绑定?