Let's learn about each http verb in brief.
The following endpoint retrieves a list of all employees.
This verb is used to create new data on the server. It is a write operation that adds a new resource to the server. A POST request is used to submit an entity to the specified resource, often causing a change in state on the server.
The following endpoint create or add the employee.
POST /api/Employee/CreateEmployee .
This verb is used to update existing data on the server. It is a write operation that replaces an existing resource with a new one. A PUT request is used to update a resource with the client-provided data.
The following endpoint updates employee with ID 1.
PUT /api/Employee/updateEmployee/1 .
This verb is used to delete data on the server. It is a write operation that removes a resource from the server. A DELETE request is used to delete a resource identified by a URI.
The following endpoint deletes employee with ID 1.
PATCHThis verb is used to update partial data on the server. It is a write operation that modifies a portion of an existing resource. A PATCH request is used to update a resource with only the specific changes provided in the request body.
Example:The following endpoint updates a specific property of employee with ID 1.
Refer to the following articles to learn how to use HTTP verbs in the ASP.NET Web API and other scenarios.
- Building CRUD Web API for Cosmos DB using C# ASP.NET Core
- CRUD Operations In ASP.NET MVC 5 Using ADO.NET
The HTTP verbs in the ASP.NET Web API provide a simple and standard way of performing CRUD (create, read, update, and delete) operations on resources. The choice of verb depends on the type of operation you want to perform on a resource. When used properly, HTTP verbs help ensure that your web API is secure, reliable, and scalable.
Post a Comment