Activity 24: POSTMAN
Step 1: Download Postman
Open your web browser and go to the official Postman website.
Choose the version of Postman compatible with your operating system:
Windows: Download the
.exe
file.macOS: Download the
.dmg
file.Linux: Choose the appropriate Linux package (Debian or Snap).
I chose Windows because that is my operating system.
Step 2: Install Postman
Windows: Double-click the .exe
file and follow the installation instructions. The installation should be automatic.
After installation, you’ll be directed to the log in page. If you still have not created an account, click “Create Free Account“
After setting up your account, you’ll be automatically directed in your postman personal workspace.
Step 3: Send Different Types of Requests
GET Request (Retrieve Data)
First, select + in the workbench to open a new tab.
After selecting a blank collection, click the 3 circles on its side.
Click ‘Add Request’.
Upon adding a request, you can change it’s request name by whatever you want. It will get reflected on the Request tab.
We shall then select the option GET from the HTTP request dropdown.
Enter an URL - https://www.tutorialspoint.com/index.htm
in the address bar and click on Send.
Response:
Once a request has been sent, we can see the response code 200 OK populated in the Response. This signifies a successful request and a correct endpoint. Also, information on the time consumed to complete the request (418 ms) and payload size (19.6 KB) are populated.
<div align="center">
You've sent your first API request.
</div>
POST Request (Send Data)
Create a new request as before.
Select POST from the method dropdown.
Then, enter an URL https://jsonplaceholder.typicode.com/users
in the address bar.
Move to the Body tab below the address bar and select the option raw and choose JSON.
Copy and paste the below information in the Postman Body tab.
{
"id": 11,
"name": "Tutorialspoint",
"username": "Test1",
"email": "abc@gmail.com",
"address": {
"street": "qa street",
"suite": "Apt 123",
"city": "Kochi",
"zipcode": "49085",
"geo": {
"lat": "-3.3155",
"lng": "94.156"
}
},
"phone": "99599125",
"website": "Tutorialspoint.com",
"company": {
"name": "Tutorialspoint",
"catchPhrase": "Simple Easy Learning",
"bs": "Postman Tutorial"
}
}
The above data that is being sent via POST method is only applicable to the endpoint: https://jsonplaceholder.typicode.com/users
.
Click on the Send button.
Response:
Once a request has been sent, we can see the response code 201 Created populated in the Response. This signifies a successful request and the request we have sent has been accepted by the server.
Also, information on the time consumed to complete the request (945 ms) and payload size (1.63 KB) are populated.
We can also see that the Response body is the same as the request body which we have sent to the server.
PUT Request (Update Data)
Before creating a PUT request, always remember that we shall first send a GET request to the server on an endpoint − https://jsonplaceholder.typicode.com/users
wherein we already did.
Create a new request as before.
Select POST from the method dropdown.
Then enter the URL - https://jsonplaceholder.typicode.com/users/1
in the address bar.
It must be noted that in a PUT request, we have to mention the id of the resource in the server which we want to update in the URL.
For example, in the above URL we have added the id 1.
Move to the Body tab below the address bar and select the option raw and JSON.
Copy and paste the below information from the POST request in the Postman Body tab. Ensure the URL and body data are appropriate for updating data.
Update the “id” to 1.
{
"id": 1,
"name": "Tutorialspoint",
"username": "Test1",
"email": "abc@gmail.com",
"address": {
"street": "qa street",
"suite": "Apt 123",
"city": "Kochi",
"zipcode": "49085",
"geo": {
"lat": "-3.3155",
"lng": "94.156"
}
},
"phone": "99599125",
"website": "Tutorialspoint.com",
"company": {
"name": "Tutorialspoint",
"catchPhrase": "Simple Easy Learning",
"bs": "Postman Tutorial"
}
}
Click on the Send button.
Response:
Once a request has been sent, we can see the response code 200 OK populated in the Response body. This signifies a successful request and the request we have sent has been accepted by the server.
Also, information on the time consumed to complete the request (294 ms) and payload size (1.34 KB) are populated. The Response body shows the id got updated to 1.
DELETE Request (Remove Data)
Before creating a DELETE request, always remember that we shall first send a GET request to the server on an endpoint − https://jsonplaceholder.typicode.com/users
wherein we already did.
Create a new request as before.
Select POST from the method dropdown and enter the URL - https://jsonplaceholder.typicode.com/users/1
in the address bar.
Click on the Send button.
Once a request has been sent, we can see the Response code 200 OK populated in the Response. This signifies a successful request and the request we have sent has been accepted by the server.
Also, information on the time consumed to complete the request (403 ms) and payload size (1.06 KB) are populated. The Response shows the status as success. The record id 1 gets deleted from the server.