1. Quick Answer
The five primary HTTP methods correspond directly to CRUD operations.
- GET retrieves data from the server.
- POST creates a new resource.
- PUT updates or completely replaces an existing resource.
- PATCH updates only specific fields of an existing resource.
- DELETE removes an existing resource.
Two interview topics appear more frequently than any others:
- PUT vs PATCH
- Idempotency
Understanding these concepts is essential for both API Testing and REST Assured interviews.
2. Comparison at a Glance
| Method | Purpose | Request Body | Idempotent? |
| GET | Retrieve data | No | Yes (Safe) |
| POST | Create a new resource | Yes | No |
| PUT | Replace or update an entire resource | Yes | Yes |
| PATCH | Update selected fields of a resource | Yes | Generally Yes |
| DELETE | Remove a resource | Usually No | Yes |
3. What Each HTTP Method Does
GET
GET retrieves information from the server.
Characteristics:
- Retrieves data only.
- Does not modify server state.
- Safe.
- Idempotent.
GET requests are intended only for reading data.
POST
POST creates a new resource.
Characteristics:
- Sends data to the server.
- Creates new records.
- Not idempotent.
Sending the same POST request multiple times typically creates multiple resources.
PUT
PUT updates or completely replaces an existing resource.
Characteristics:
- Requires the complete resource representation.
- Replaces the existing resource.
- Idempotent.
Sending the same PUT request repeatedly leaves the resource in the same final state.
PATCH
PATCH modifies only the fields included in the request.
Characteristics:
- Partial updates.
- Smaller request payload.
- Does not require sending the complete resource.
- Generally idempotent when implemented correctly.
PATCH is useful when only selected attributes need to change.
DELETE
DELETE removes an existing resource.
Characteristics:
- Deletes server-side resources.
- Generally does not require a request body.
- Idempotent.
Deleting the same resource multiple times still leaves it deleted.
4. PUT vs PATCH (The Most-Asked Interview Question)
The primary difference is straightforward:
- PUT replaces the entire resource.
- PATCH updates only the specified fields.
Practical Example
A common real-world approach is:
- Use PUT for complete profile updates where every field is supplied.
- Use PATCH when updating only selected fields such as:
- Email address
- Password
- Phone number
Best Practices
When discussing PUT and PATCH during interviews, mention:
- Return 200 OK after a successful PUT request.
- Return 204 No Content after a successful PATCH request.
- Ensure PATCH updates only the supplied fields and does not unintentionally remove existing data.
5. Idempotency Explained
An operation is idempotent if performing the same request multiple times produces the same final result as performing it once.
Idempotent Methods
- GET
- PUT
- DELETE
Non-Idempotent Method
- POST
Example
A common API test case is verifying PUT idempotency.
Execute the same PUT request multiple times and confirm that the resource remains in the same final state after each request.
6. Can GET Create a Resource?
No.
A GET request should never create or modify resources.
GET is designed only for retrieving information.
Reasons
- GET is intended for data retrieval.
- GET should not change server state.
- GET requests generally do not contain a request body.
- GET responses are frequently cached by browsers, proxies, and intermediaries.
- RESTful APIs follow standard HTTP method conventions:
- POST → Create
- PUT → Update or Replace
- GET → Retrieve
Using GET to create resources breaks REST principles and can lead to unpredictable application behavior.
For complete explanations and implementation examples, refer to the Complete API Testing Guide and the Complete REST Assured Guide.
Frequently Asked Questions
What is the difference between PUT and PATCH?
PUT replaces the entire resource.
PATCH updates only the specific fields included in the request.
Which HTTP methods are idempotent?
The commonly used idempotent methods are:
- GET
- PUT
- DELETE
POST is not idempotent because each request typically creates a new resource.
What status codes should PUT and PATCH return?
Typical successful responses are:
- PUT:
200 OK - PATCH:
204 No Content
Can GET create a resource?
No.
GET should only retrieve data and should never modify server state.
Use:
- POST for creating resources.
- PUT for replacing or updating resources.
How do you test PUT idempotency?
Execute the same PUT request multiple times and verify that the resource remains in the same final state after every execution.