使用 "frombody" 属性,Web Api 方法的参数在使用 Postman 进行测试时收到空值

With "frombody" attribute, parameter of Web Api method recieves null value while testing it with Postman

下面是我的 WebApi 方法,我想用 Postman 测试它,但是每当我提交请求时,myKey 总是包含空值。

[Route("Complete")]
[HttpPost]
[Authorize]
public async Task<IHttpActionResult> Complete([FromBody]string myKey)
{
    // My logic
}

这就是我通过 Postman 提交请求的方式。

我发现很多 post 建议我们如何从 Web 提交数据,但没有一个使用 Postman 显示相同的数据。

能否指导我通过 Postman 工具获取 myKey 的值?

仅传递请求正文中的值。当您为像 string 这样的简单类型参数添加 [FromBody] 属性时,正文将被读取为字符串。