From the course: Building Angular and ASP.NET Core Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Update API endpoint

Update API endpoint

From the course: Building Angular and ASP.NET Core Applications

Start my 1-month free trial

Update API endpoint

- [Instructor] So far we know how to add new data and how to read them, but sometimes users might enter bad data. So, we should give them the ability to update their existing data. For that we are going to create an update API endpoint. In here we need to go inside the Controllers folder and then BooksController.cs file. Just after the ReadAllBooks, we are going to add a new endpoint for updating an existing book. This is going to be an HTTP put request, so for that we write in here http put and then we write public IActionResult, UpdateBook. Of course in the HTTP put, we can define the URL. So for that we write, inside double quotes UpdateBook and we are going to pass as the URL parameter, the book ID. So just write ID in there and the UpdateBook method is going to take two parameters. The first parameter is going to be the ID of the book we want to update and the second parameter, which we are going to pass as a body…

Contents