2

I have an API with a

[HttpPost("InsertSomething")]
public async Task<IActionResult> InsertSomething(Guid id, [FromBody] MyModel model)
{
   try
   {
      ...
      Guid somethingId = await _myService.Insert(id, enz..)

and when I wanna calling this Action

HttpResponseMessage result = await client.PostAsync("/MyContr/InsertSomething", content);

then i will come in the Action of the API.

... and when you add something like this

HttpResponseMessage result = await client.PostAsync($"/MyContr/InsertSomething?id=BlaBlaBla", content);

then we did not comein the Action of the API.

How can I solve this problem?

user1531040
  • 2,143
  • 6
  • 28
  • 48

1 Answers1

3

You can change your endpoint like this:

 [HttpPost("InsertSomething")]
 public async Task<IActionResult> InsertSomething([FromQuery]Guid id, [FromBody] MyModel model)

also, make sure that you are passing correct guid.

Nemanja Todorovic
  • 2,521
  • 2
  • 19
  • 30