- Get
- Post
- Put
- Delete
- Patch
Let's learn about each http verb in brief.
GET :
Example:
The following endpoint retrieves a list of all employees.
GET /api/Employee/ListEmployees
POST
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.
Example:
The following endpoint create or add the employee.
POST /api/Employee/CreateEmployee
.
PUT
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.
Example:
The following endpoint updates employee with ID 1.
PUT /api/Employee/updateEmployee/1
.
DELETE
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.
Example:
The following endpoint deletes employee with ID 1.
DELETE /api/Employee/deleteEmloyee/1
.
PATCH
This 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.PATCH /api/Employee/partialupdate/1
- Building CRUD Web API for Cosmos DB using C# ASP.NET Core
- CRUD Operations In ASP.NET MVC 5 Using ADO.NET
Summary
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