What is an HTTP method?
An HTTP method is a part of an HTTP request that tells the server exactly what the client wants to do with a resource.
In simple terms: an HTTP method answers the question: "what action should be performed?"
Why HTTP methods are needed
The same URL can be used for different actions. An HTTP method lets the server understand the client's intent.
For example:
- get data
- send data
- change data
- delete data
Without methods, the server would not know what exactly is wanted from it.
The most basic HTTP methods
GET, get data
Used to:
- get a page
- request data from an API
Example:
"Give me the list of users"
GET does not change data on the server.
POST, send data
Used to:
- submit a form
- create a new object
- send data to the server
Example:
"Create a new user with this data"
PUT, replace data
Used to:
- fully update a resource
Example:
"Replace the user's data entirely"
PATCH, partially change data
Used to:
- change only part of a resource
Example:
"Update only the user's email"
DELETE, delete data
Used to:
- delete a resource
Example:
"Delete the user"
Why HTTP methods matter
HTTP methods:
- make an API clear and predictable
- help separate the logic of actions
- are used in REST and web services
- matter for security and caching
For example:
- GET can be cached
- POST usually cannot
Real-life example
A URL is a store's address. An HTTP method is the action:
- GET → look at a product
- POST → place an order
- DELETE → cancel an order
The address is the same, the action is different.
Key points for an interview
- a method is not a URL
- a method is a verb, an action
- the server itself decides what to do with the method
- the wrong method → an error (for example, 405 Method Not Allowed)
Short answer for an interview
Remember this wording:
An HTTP method is a part of an HTTP request that defines the type of operation the client performs on a resource on the server, for example retrieving, creating, changing, or deleting data.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.