HTTP Methods :

HTTP (Hypertext Transfer Protocol) defines several methods or verbs that indicate the desired action to be performed on a resource. The commonly used HTTP methods are as follows:


GET : Retrieves data or a representation of a resource from the server. It should not have any side effects on the server or the resource itself.

Here's an example of how to send an HTTP GET request using Postman:

Open Postman and create a new request by clicking on the "New" button.

Select the HTTP method as "GET" from the dropdown menu.

Enter the request URL in the address bar. For example, http://example.com/api/users.

If needed, you can add query parameters to the URL by clicking on the "Params" button below the address bar. This allows you to pass additional information to the server. For instance, you can add a parameter called "id" with a value of "123" to retrieve a specific user: http://example.com/api/users?id=123.

Click the "Send" button to send the GET request.

Postman will send the HTTP GET request to the specified URL with any query parameters included. The server will process the request and return the response, which can be viewed in the "Response" section of Postman. This response typically contains the requested data or information from the server.

POST: Submits data to be processed to the server. It is often used to create new resources or trigger actions that modify the server's state.

Here's an example of how to send an HTTP POST request using Postman, a popular API testing and development tool:

Open Postman and create a new request by clicking on the "New" button.

Select the HTTP method as "POST" from the dropdown menu.

Enter the request URL in the address bar. For example, http://example.com/api/users.

Go to the "Body" tab below the address bar.

Choose the format for the request body. For this example, select "Raw" and choose "JSON (application/json)" from the dropdown menu.

In the text area below, enter the JSON data you want to send in the request body. For instance:

json
{ "name": "John Doe", "age": 30 }
  1. Click the "Send" button to send the POST request.

Postman will send the HTTP POST request to the specified URL with the provided data in the request body. The server will then process the request and perform the necessary actions based on the API's implementation.

PUT: Updates or replaces a resource's representation with the provided data. It can be used to create a new resource if the resource doesn't exist at the specified URI.

Here's an example of how to send an HTTP PUT request using Postman:

Open Postman and create a new request by clicking on the "New" button.

Select the HTTP method as "PUT" from the dropdown menu.

Enter the request URL in the address bar. For example, http://example.com/api/users/123, where "123" is the identifier of the user you want to update.

Go to the "Body" tab below the address bar.

Choose the format for the request body. For this example, select "Raw" and choose "JSON (application/json)" from the dropdown menu.

In the text area below, enter the JSON data you want to send in the request body. This data should represent the updated information for the user. For instance:

json
{ "name": "John Doe", "age": 35 }
  1. Click the "Send" button to send the PUT request.

Postman will send the HTTP PUT request to the specified URL with the provided data in the request body. The server will then process the request and update the user's information based on the API's implementation. The response from the server can be viewed in the "Response" section of Postman.

PATCH: Partially updates a resource. It is used to apply modifications to a resource without requiring the entire resource to be sent back to the server.

Here's an example of how to send an HTTP PATCH request using Postman:

Open Postman and create a new request by clicking on the "New" button.

Select the HTTP method as "PATCH" from the dropdown menu.

Enter the request URL in the address bar. For example, http://example.com/api/users/123, where "123" is the identifier of the user you want to partially update.

Go to the "Body" tab below the address bar.

Choose the format for the request body. For this example, select "Raw" and choose "JSON (application/json)" from the dropdown menu.

In the text area below, enter the JSON data you want to send in the request body. This data should contain only the fields that you want to update for the user. For instance:

json
{ "age": 35 }
  1. Click the "Send" button to send the PATCH request.

Postman will send the HTTP PATCH request to the specified URL with the provided data in the request body. The server will then process the request and apply the partial update to the user's information based on the API's implementation. The response from the server can be viewed in the "Response" section of Postman.

DELETE: Removes a specified resource from the server.

Here's an example of how to send an HTTP DELETE request using Postman:

Open Postman and create a new request by clicking on the "New" button.

Select the HTTP method as "DELETE" from the dropdown menu.

Enter the request URL in the address bar. For example, http://example.com/api/users/123, where "123" is the identifier of the user you want to delete.

If needed, you can add query parameters to the URL by clicking on the "Params" button below the address bar. This allows you to pass additional information to the server. However, DELETE requests typically do not have a request body.

Click the "Send" button to send the DELETE request.

Postman will send the HTTP DELETE request to the specified URL. The server will then process the request and delete the corresponding user or resource based on the API's implementation. The response from the server can be viewed in the "Response" section of Postman. Note that DELETE requests are intended to be irreversible, so exercise caution when using them.

HEAD:The HTTP HEAD method is typically used to retrieve the headers of a resource without fetching the entire resource itself. Here's an example of how to send an HTTP HEAD request using Postman:

Open Postman and create a new request by clicking on the "New" button.

Select the HTTP method as "HEAD" from the dropdown menu.

Enter the request URL in the address bar. For example, http://example.com/api/users/123, where "123" is the identifier of the resource you want to retrieve the headers for.

Click the "Send" button to send the HEAD request.

Postman will send the HTTP HEAD request to the specified URL. The server will then process the request and return only the headers of the resource in the response. The response headers can be viewed in the "Headers" section of Postman's response pane. The actual content of the resource will not be included in the response since the HEAD method only retrieves the headers.

OPTIONS: Retrieves the available communication options for a given resource. It provides information about the supported methods, headers, and other capabilities of the server.

The HTTP OPTIONS method is used to retrieve the available communication options for a given resource. Here's an example of how to send an HTTP OPTIONS request using Postman:

Open Postman and create a new request by clicking on the "New" button.

Select the HTTP method as "OPTIONS" from the dropdown menu.

Enter the request URL in the address bar. For example, http://example.com/api/users.

Click the "Send" button to send the OPTIONS request.

Postman will send the HTTP OPTIONS request to the specified URL. The server will then process the request and return the response, which typically includes information about the supported methods, headers, and other capabilities of the server for the requested resource.

In Postman, the response will be displayed in the "Response" section. You can view the headers and other relevant information provided by the server in response to the OPTIONS request. This allows you to understand the available communication options and capabilities of the server for the specified resource.

These HTTP methods allow clients (such as web browsers) to interact with servers and perform various actions on resources over the web.