我有一个带有的API
[HttpPost("InsertSomething")]
public async Task<IActionResult> InsertSomething(Guid id, [FromBody] MyModel model)
{
try
{
...
Guid somethingId = await _myService.Insert(id, enz..)
当我想叫这个行动
HttpResponseMessage result = await client.PostAsync("/MyContr/InsertSomething", content);
然后我将参加API的行动。
当你添加类似的东西时
HttpResponseMessage result = await client.PostAsync($"/MyContr/InsertSomething?id=BlaBlaBla", content);
然后我们没有参加API的行动。
我该如何解决这个问题?
您可以这样更改端点:
[HttpPost("InsertSomething")]
public async Task<IActionResult> InsertSomething([FromQuery]Guid id, [FromBody] MyModel model)
此外,请确保您正在传递正确的guid。