MWZ

MINDWAREZONE

Difference Between GET, POST, PUT, PATCH & DELETE Methods

GET

  • Used to retrieve data from the server.
  • Should not modify any data.
  • Data is usually sent through the URL as query parameters.
  • Example: Viewing a list of users.
GET /users
            

POST

  • Used to create new resources on the server.
  • Sends data in the request body.
  • Example: Creating a new user.
POST /users
            

PUT

  • Used to update an entire resource.
  • Typically replaces all fields of the existing resource.
  • Example: Updating all details of a user.
PUT /users/1
            

PATCH

  • Used to partially update a resource.
  • Updates only the fields that need to change.
  • Example: Updating only a user's email address.
PATCH /users/1
            

DELETE

  • Used to remove a resource from the server.
  • Example: Deleting a user.
DELETE /users/1
            

Quick Comparison

Method Purpose Example
GET Retrieve data Get all users
POST Create new data Create a user
PUT Update entire resource Update all user details
PATCH Update specific fields Update user's email
DELETE Delete data Delete a user