更新时间:2023-02-25 16:54:28
创建与您的JSON相对应的类:
Create a class that corresponds to your JSON:
public class Test
{
public string value{get; set;}
public int ID {get; set;}
}
然后更改您的Api动作:
And then change your Api-action:
// POST api/myfiles
public void Post([FromBody]Test value)
{
}
如果您不想这样做,只需更改POST-body:
If you don't want to do that, just change the POST-body:
"somevalue"
编辑:将ID添加到POST有效负载中. 现在,您的JSON应该如下所示:
EDIT: Added ID to the POST-payload. Now your JSON should look like this:
{"value": "someval",
"ID": 1}