1
I’m having the following error, I perform the following operation:
// POST: api/Funcionario/AddFuncionario
[HttpPost("AddFuncionario")]
public IActionResult AddFuncionario([FromBody] Funcionario Func)
{
if(Func == null)
{
return BadRequest();
}
funcionarioRepository.AddFuncionario(Func);
return CreatedAtRoute("BuscarPorId/{id}", new { id = Func.Id }, Func);
}
only that, on my return Createdatroute, the action Buscarporid is not being found, the following error appears: Invalidoperationexception: No route Matches the supplied values.
Follow my Api Action:
[HttpGet("BuscarPorId/{id}")]
public IActionResult BuscarPorId(int id)
{
var item = funcionarioRepository.BuscarPorFuncionario(id);
return new ObjectResult(item);
}
Okay, I did the following, named my request: [Httpget("Buscarporid/{id}", Name = "Buscarporid")] and in Return createdAtroute it looks like this: Return Createdatroute("Buscarporid", new { id = Func.Id }, Func);
– Thiago Oliveira