Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

when pass id value of put(update) from postman it passed as 0 although it have value on link

$
0
0

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://localhost:44326/api/Employee/put?id=5

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 

  [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(); }

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 ?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>