HTTP methods define the actions that can be performed on resources. Here are some of the commonly used HTTP methods:
- GET: Retrieve data from a server.
- POST: Send data to a server to create or update a resource.
- PUT: Update a resource on the server.
- DELETE: Remove a resource from the server.
- PATCH: Apply partial modifications to a resource.
For more information about HTTP methods, you can visit our HTTP Methods Guide.
GET Method
The GET method is used to retrieve data from a server. It is the most commonly used HTTP method. When you use the GET method, the data is appended to the URL as query parameters.
Example:
GET /api/users?name=John&age=30
POST Method
The POST method is used to send data to a server to create or update a resource. The data is included in the body of the request.
Example:
POST /api/users
Content-Type: application/json
{
"name": "John",
"age": 30
}
PUT Method
The PUT method is used to update a resource on the server. The entire resource is included in the body of the request.
Example:
PUT /api/users/123
Content-Type: application/json
{
"name": "John",
"age": 30
}
DELETE Method
The DELETE method is used to remove a resource from the server.
Example:
DELETE /api/users/123
PATCH Method
The PATCH method is used to apply partial modifications to a resource. The changes are included in the body of the request.
Example:
PATCH /api/users/123
Content-Type: application/json
{
"age": 31
}