![](/img/trans.png)
[英]Web API to API call always receives null as input parameter : .Net Core
[英].NET Core API - Why is file attribute in nested model receives null?
我有一个嵌套的 model。 当我使用 Postman 发出发布请求时,我可以获得除嵌套File
属性之外的所有属性。 为什么只有嵌套文件属性来自 null,解决方案是什么? 嵌套的 model 和请求截图如下:
public class RequestDTO
{
public int Id { get; set; }
public string Name { get; set; }
public IFormFile Image { get; set; }
public TestModel Test { get; set; }
}
public class TestModel
{
public string Desc { get; set; }
public IFormFile File { get; set; }
}
使用Test.file
而不是Test[file]
。
curl --location --request POST 'https://localhost:7212/weatherforecast' \
--form 'id="1212"' \
--form 'name="qweqweqw"' \
--form 'image=@"/<Folder-path>/sun-flower-transparent-background-additional-png-file-greeting-cards-holiday-wishes-sun-flower-transparent-129371261.jpg"' \
--form 'Test[desc]="csdds"' \
--form 'Test.file=@"/<Folder-path>/Fruit-PNG.png"'
演示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.