problem
when pass id value of put(update) from postman it passed as 0 although it have value on link ?
i select key from post man as contenttype application/json
and this is my url
https:
and when put breakpoint in function put and run app
it hit breakpoint but id return with 0 although i have 5 in my link
and 5 also exist on database
when run API update from angular 6 it give me bad request because id is passing by 0 ?
why is pass id as 0 and how to solve this problem ?
I work with asp.net core 2.1 visual studio 2017
and I have this function above on controller Employee
this is only function update (put) for my controller
so that how to solve problem passing 0 and
what is correct link if above is wrong ?
What I have tried:
[Produces("application/json")]
[Route("api/Employee")]
public class EmployeeController : Controller
{
[HttpPut("{id}")]
public IActionResult PutEmployee(int id, [FromBody] Employee employee)
{
if (id != employee.EmployeeId)
{
return BadRequest();
}
try
{
_repository.Update(employee);
}
catch (DbUpdateConcurrencyException)
{
if (!EmployeeExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return Ok();
}