Top 9 HTTP Request Methods
Today, we will learn the Top 9 HTTP Request methods. HTTP set of request methods to indicate the desired action to be performed for a given resource. HTTP request is made by a client, which is located on a server. and The main use of the request is to access a resource on the server.
Table of concept
1. GET
GET Method Retrieves data from the server. it should only retrieve data and should have no other effect on the data.
Example
GET /api/employees/{employee-id}
The above example returns a specific employee by Employee ID.
2. POST
POST Method Used to send data to a server to create a new resource. the data is included in the body of the request.
Example
POST /api/employees/department
The above example Creates a department resource.
3. PUT
The PUT Method is similar to POST, but it’s used to update existing resources. the entire resource is updated at once.
Example
PUT /api/employees/16
The above example Update employee by employee ID.
4. PATCH
PATCH Method is used to update resources but it only updates the fields that were included in the request.
Example
PATCH /api/employees/16{"name": "John"}
The above example Updates the name for employee id 16.
5. DELETE
DELETE Method deletes a resource, Regardless if the number of calls, it returns the same result.
Example
DELETE /api/employees/16
The above example is Delete employee by Employee ID.
6. HEAD
HEAD Method Typically this is used to check if a resource is available and to get the metadata.
Example
HEAD /api/employees
The above example is Similar to GET, but it does not return the list of employees.
7. OPTIONS
The OPTIONS Method is used to get information about the possible communication options for the given URL or an asterisk to refer to the entire server.
Example
OPTIONS /api/index.html/1.2
The above example Returns the Permitted HTTP Method in this URL.
8. TRACE
TRACE Method Is for diagnosis purposes. it echoes the received request so that a client can see what changes or additions have been made by intermediate servers.
Example
TRACE /api/index.html
The above example Responds to the exact request that the client sent.
9. CONNECT
CONNECT Method is for making end-to-end connections between a client and a server. It makes a two-away connection like a tunnel between them.
Example
CONNECT www.devnote.in:443HTTP/1.2
The above example connects to the URL Provided.