我宣布了非常简单的API方法
[RoutePrefix("api/reports")]
public class HomeController : ApiController
{
[HttpPost]
[Route("person/{name}/{year}/{month}", Name = "SaveReport")]
public IHttpActionResult SaveReport(string name, int year, int month, [FromBody] myModel model)
{
return Ok("hi");
}
}
并拥有一个简单的Model类
public class myModel
{
private string param { get; set; }
}
我尝试使用Postman或fiddler调用API方法,但它返回错误
来自邮递员的电话:请求实体的媒体类型" multipart / form-data'此资源不支持
api/reports/person/reza/2017/23 Content-Type: application/json;
Body: {"model" : "this is param field content"}