我在.js文件中有以下提取
fetch('api/SampleData/GetBpmnXml', {
method: 'post',
body: {
"first_name": "Bob"
}
})
在API我有这个帖子
[HttpPost]
public void Post([FromBody] string first_name)
{ return first_name;}
为什么返回值为null?而不是鲍勃?
请参阅body部分,参数名称为first_name
,而不是api端点中的value
。可能会将您的Api端点更改为以下;这样它就可以绑定到参数
[HttpPost]
public void Post([FromBody] string first_name)
{ return value;}