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

Unlock the full course today

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

Update API endpoint

Update API endpoint

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

Start my 1-month free trial

Update API endpoint

- [Instructor] So now we can add new trips and we can read all of them. But what if we enter some bad information when we create new trips? For that, we need to be able to modify the existing trips. So we need to go to our controller and create a new API Endpoint to update the data. In here, go to the Controllers folder, and then TripsController.cs file. Just after the AddTrip, we are going to create a new endpoint. Now since we want to update the data, we are going to send an HttpPut request and we are going to name the url or the API endpoint UpdateTrip. Then, as part of the url, we are going to have a parameter id. So let's write down here, public IActionResult UpdateTrip. This will take two parameters, the trip id, which is going to be part of the url, so int id, and from the request body we want to send the data of the new trip, so the updated values of the trip. So let's write in here [FromBody]Trip, and…

Contents