top of page

API testing using Postman

In this blog we will learn about API testing using postman step by step.

What is API?

An API is an interface or communication protocol between a client & a server that intends to simplify the client-side application for a better user experience.

API testing can be performed either manually using Postman tools or by automation using available dependency code for Rest Assured. Here we are going to discuss API Testing with REST Assured and API testing with Postman Tool.


Methods in API testing

GET Method: When we want to fetch data from the server then, we use the GET method to fetch the data.

POST Method: When we want to create some new resource on the server, then we use the POST method.

PUT Method: When we want to update any existing resource, then we use the PUT method to modify it. If the parameter which we want to update is available, then it modifies that parameter. If that parameter is not available, then it creates that parameter.

DELETE Method: When we want to do a partial update then, we use the PATCH method to update. We pass only that parameter that we want to update, we don’t have to pass a complete payload to update the resource.



Working with GET Requests

GET Requests are used for retrieving data from a particular URL and no changes would be made to the URL. We will follow the given URL for all Postman examples in the guide.

Step 1: In the workspace, set the HTTP request to GET request.

Step 2: In the request URL field, add link and click Send.

Step 3: Lastly, you will see almost 200 OK Message. There will be 10 user results in the body that will highlight the successful running of the test.

Working with POST Requests

POST Requests differ from GET requests as they involve data manipulation with the users inserting more data into the API endpoint. We are using the same data from GET requests to work on SET Requests.

Step 1: Choose a new tab and create a new request.

Step 2: In this new tab, configure the HTTP request to POST request and add the same link in the request URL and switch to body tab.

Step 3: In the body, open Raw and choose JSON file format.

Step 4: Paste a single user result from the previous GET request as shown below. Make sure the code is pasted correctly with braces and brackets. Next, change the ID to 11 and name it.

        "id": 11,
        "name": "Krishna Rungta",
        "username": "Bret",
        "email": "",
        "address": {
            "street": "Kulas Light",
            "suite": "Apt. 556",
            "city": "Gwenborough",
            "zipcode": "92998-3874",
            "geo": {
                "lat": "-37.3159",
                "lng": "81.1496"
        "phone": "1-770-736-8031 x56442",
        "website": "",
        "company": {
            "name": "Romaguera-Crona",
            "catchPhrase": "Multi-layered client-server neural-net",
            "bs": "harness real-time e-markets"

Step 5: Next, click on send and status 201 will be displayed. The posted data will be shown in the body.

How Can You Parameterize Requests in Postman?

Data parameterization is the procedure of converting test values into reusable parameters. It helps in avoiding same tests repetition and iterations. To create parameterize requests, follow the below steps:

Step 1: Set the HTTP request to GET request and add the same link as used above

Step 2: Replace the initial part of the link with parameters like {{url}}. After that, your request URL will be shown like {{url}}/users and click send. There will be no response because the source of parameter has not been configured.

Step 3: To utilize the parameter, you must configure the environment. For that, click on the eye icon and open Edit to set variable in a global environment to be used in all test collections.

Step 4: In variable, name the URL which you have used, i.e. and click save.

Step 5: Select close in case you see the upcoming screen. Return to GET request and click send. After that, your request results will be displayed.

Creating Postman Tests

Postman Tests are JavaScript codes which are added to requests to verify results like successful or failed testing, comparing expected outcomes, etc. Here are the steps that you need to follow to perform basic API testing for parameterize requests.

Step 1: Go to the GET user request from the previous section and switch to tests tab. Next, on the right side, you will see code snippets.

Step 2: Within the snippet section, open “Status code: Code is 200”. The window will automatically pop up as shown below.

Step 3: Next click on Send and test results will be displayed. After that, go to the test tab and add one more test. This time, it will be a comparison between the expected and the actual outcomes.

Step 4: From the snippets section, select “Response body: JSON value check” to check if Leanne Graham has the user id 1.

Step 5: Replace “Your Test Name” with “Check if user with id1 is Leanne Graham” to specify what you need to check.

Step 6: Change json Data.value with jsonData[0].name and to get the path, check the body early in GET results. Because Leanne Graham is userid 1, json Data must start with O. To get the second result, utilize json Data[1], and so on for upcoming outcomes. Lastly, in to eql, add “Leanne Graham” as shown below.

Step 7: Tap on send and two passed test results will be displayed for the request.

How to Create Requests Collections?

Collections are important to organize the API test suites and can be easily shared among the team members. Here are the steps you need to follow to create one:

Step 1: Press the New button from the top left corner of the page.

Step 2: Choose Collection and a new collection window will pop up.

Step 3: Add the collection name and description, a new collection will be created.

Step 4: Go to the previous GET request and click on save.

Step 5: Select Postman Test Collection and click on Save to Postman Test Collection.

Step 6: Postman test collection will now contain one request and follow steps 4-5 times for the previous Post request so the collection will have two requests.

How to Run Collections via Collection Runner?

Let’s learn the steps to run and test multiple API collections with Collection Runner:

Step 1: Click on the Runner button at the top of the page

Step 2: Collection Runner page will pop up along with description of several fields

Step 3: Run the Postman Test Collection by selecting collection and setting Iterations as 3. Next, you need to set the time 2500s to execute requests.tly, click on the Run Test option.

Step 4: Test Run Results page will be shown after you click the Run button. Here you will be able to see the test results as per the iteration done. It will show the pass status for GET requests. Since we did not have tests for post requests, you will get the message “the request did not have any tests.”

How to Run Collections Through Newman?

To run collections from Newman, first install it using Next, open the command line and add npm install -g newman.

Step 1: In the Collections box, go to three dots and select Export.

Step 2: Select Export Collection as Collection v2.1 (Recommended) and click Export. Next, select the location to save collection and click save.

Step 3: Next, to export the environment, click on the eye icon in the environment dropdown in Global and select Download as JSON. After that, select the location and save the environment.

Step 4: Next, return to the command line and change the directory to where you saved the collection and the environment.

cd C:\Users\Asus\Desktop\Postman Tutorial

Step 5: Run the collection by entering this command

newman run PostmanTestCollection.postman_collection.json -e Testing.postman_globals.json

After that the results will appear.

72 views0 comments

Recent Posts

See All


Mit 0 von 5 Sternen bewertet.
Noch keine Ratings

Rating hinzufügen
bottom of page