The HTTP methods of an endpoint define the type of action it performs on a given resource. Some common HTTP methods are GET, POST, DELETE, and PATCH. It provides the HTTP method for every endpoint. HTTP methods include:
- GET: Used for retrieving resources.
- POST: Used for creating a new resource.
- PATCH: Used for updating properties of resources.
- PUT: Used for replacing resources or collections of resources.
- DELETE: Used for deleting resources.
Difference Between PATCH and PUT
PATCH: requests are used to make partial updates on a resource.
PUT: requests are used to modify/replace all resource entities.
The table below summarises the use of HTTP methods discussed above
| HTTP Methods | CRUD | Description |
|---|---|---|
| POST | Create | It submits data to the server and the server processes it, creating a new resource. |
| GET | Read | It requests data from the server without modifying it. |
| PATCH | Partial Update/Modify | It modifies the fields that are provided in the request body. |
| PUT | Update/Replace | The entire resource is typically replaced with the new data sent in the request body |
| DELETE | Delete | It requests the server to remove the specified resource |