DEV Community

Cover image for What is HTTP methods (GET, POST, PUT, DELETE)?
Sharath Kumar
Sharath Kumar

Posted on

What is HTTP methods (GET, POST, PUT, DELETE)?

HTTP methods define what action you want to perform on a resource in a web application. They are the foundation of REST APIs and are widely used in Java backend development.


πŸ” What is an HTTP Method?

An HTTP method is a verb that tells the server:
πŸ‘‰ β€œWhat should I do with this data?”


πŸ“Œ 1. GET – Retrieve Data

GET is used to fetch data from the server.

βœ… Features:

  • Read-only (no changes to data)
  • Idempotent (same result every time)
  • Safe operation

πŸ§ͺ Example:

```http id="g1"
GET /users/101




πŸ‘‰ Fetch user with ID 101

---

## πŸ“Œ 2. POST – Create Data

**POST** is used to **create a new resource**.

### βœ… Features:

* Adds new data
* Not idempotent
* Multiple requests create multiple records

### πŸ§ͺ Example:



```http id="p1"
POST /users
{
  "name": "Harish"
}
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Creates a new user


πŸ“Œ 3. PUT – Update/Replace Data

PUT is used to update or completely replace an existing resource.

βœ… Features:

  • Idempotent
  • Replaces entire resource

πŸ§ͺ Example:

```http id="pu1"
PUT /users/101
{
"name": "Harish Kumar"
}




πŸ‘‰ Updates user 101

---

## πŸ“Œ 4. DELETE – Remove Data

**DELETE** is used to **remove a resource**.

### βœ… Features:

* Idempotent
* Removing again gives same result

### πŸ§ͺ Example:



```http id="d1"
DELETE /users/101
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Deletes user 101


βš”οΈ Quick Comparison

Method Purpose Idempotent Safe Example Use
GET Read data βœ… Yes βœ… Yes Fetch user
POST Create data ❌ No ❌ No Create user
PUT Update/Replace βœ… Yes ❌ No Update user
DELETE Remove data βœ… Yes ❌ No Delete user

πŸ’‘ Real-Time Flow

In a typical application:

  1. GET β†’ Load data on UI
  2. POST β†’ Submit form
  3. PUT β†’ Edit/update data
  4. DELETE β†’ Remove records

πŸš€ Why Are HTTP Methods Important?

  • Standard way of communication in web apps
  • Helps design clean REST APIs
  • Improves scalability and maintainability

🎯 Conclusion

Understanding HTTP methods is crucial for backend developers. Each method has a specific purpose and using them correctly ensures your APIs are clean, predictable, and scalable.


πŸ”₯ Learn More

Want to master REST APIs, Spring Boot, and backend development?

πŸ‘‰ No 1 Core JAVA Online Training in 2026


Top comments (0)