【发布时间】:2021-10-11 22:57:57
【问题描述】:
我正在向 API 端点 http://localhost:20779/api/Account 发出 POST 请求并收到以下错误。
无法将 JSON 值转换为 System.String。路径:$ | 行号:0 | BytePositionInLine:1。”
这是我用来发出 POST 请求的 JSON。
{
"EmailAddress": "hello@example.com",
"Username": "example",
"Password": "mypassword",
"Status": "A",
"CreatedOn": "2021-08-10 08:00:00"
}
请求命中 POST 方法。
namespace HelpDesk.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class AccountController : ControllerBase
{
// POST api/<AccountController>
[HttpPost]
public void Post([FromBody] string value)
{
var x = string.Empty;
}
}
}
【问题讨论】:
标签: c# asp.net .net-core webapi asp.net-core-5.0