【发布时间】:2017-08-08 03:25:13
【问题描述】:
我试图只传递 body 和 int 但它不起作用
为什么我需要创建一个具有 int 类型属性的类? (然后就可以了)
有效
[HttpPost]
[Route("api/UpdateMainReversed")]
public IHttpActionResult UpdateMainVerified(DataAccess.Entities.RequestMain mainValues)
{ ....}
不工作
[HttpPost]
[Route("api/UpdateMainReversed")]
public IHttpActionResult UpdateMainVerified(int mainId)
{ ....}
使用 Postman 进行测试
http://localhost:13497/api/UpdateMainReversed
身体
{
"mainId" : 1615
}
【问题讨论】:
-
你想在 body 或 url 中传递 int?
-
body,因为它的 POST 并且不应该传递 URL 以获取正确的 REST
-
检查我的答案。
标签: c# asp.net-web-api asp.net-web-api2 postman asp.net-web-api-routing