复杂 POST 参数始终为空
本文关键字:POST 参数 复杂 | 更新日期: 2023-09-27 17:57:23
>当我向以下操作发出发布请求时
[HttpPost]
public ResponseOutput Incremental(List<Product> inputList)
{
return true;
}
参数输入列表始终为空。我的对象:
public class Product
{
public string ContractNo { get; set; }
public string Sku { get; set; }
public double Alis { get; set; }
public string Kur { get; set; }
public string SupplierNumber { get; set; }
public ActionType Islem { get; set; }
}
操作类型是枚举。
和我的请求正文:
POST /api/Konsinye/ConsigneeInsertIncremental HTTP/1.1
Host: localhost:38664
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 9e5f759c-552d-2e3e-f704-28ec91045e6c
{
"inputList" : [
{
"ContractNo" : "123",
"Sku" : "1234",
"Alis" : "112",
"Kur" : "TRY",
"SupplierNumber" : "000",
"Islem" : "1"
}
]
}
问题是,参数始终为空。我尝试将[FromBody]添加到签名中,但没有帮助。
尝试这种方法(将对象数组传输到服务器,而不是使用数组属性的单个对象):
[HttpPost]
public IHttpActionResult Incremental(List<ConsigneeProductInput> data)
{
return Ok();
}
邮递员的身体:
[
{
"ContractNo" : "123",
"Sku" : "1234",
"Alis" : "112",
"Kur" : "TRY",
"SupplierNumber" : "000",
"Islem" : "1"
}
]