Section 7: Creating a PUT method(Restful API in ASP .Net Core)

 

Section 7: Creating a PUT method(Restful API in ASP .Net Core)


Introduction:

In section 5 and 6, we have seen how to add a GET and POST method. In this section, let us add a PUT method. PUT method is used to update a record. 

To add Put method,

  • Create a Put() method in the controller class. This method return void and accepts a Model (which holds the new data) and the id of the model to be updated.
  • Add an Attribute HttpPut("{id:int}")
  • Update the List.

Let us see this in action:



Test it as we did before using Postman.