top of page

Welcome
to NumpyNinja Blogs

NumpyNinja: Blogs. Demystifying Tech,

One Blog at a Time.
Millions of views. 

Postman Collections and Newman Report (How to run group requests in Postman and generate Newman report)

Updated: Jun 27


Postman:

Postman is a collaboration and testing tool for APIs (Application Programming Interfaces) that work over the internet. API is like an outlet that a server offers and instead of electricity we get data. We use postman to plug into this outlet but instead of using a physical cable we use internet. Postman can help us connect to that API and make sure that the process of sending and receiving data is much easier. Without that interface to the server it will be much harder to communicate so this is why we need postman. It has the ability to make various types of HTTP requests(GET, POST, PUT, PATCH), save environments for later use, converting the API to code for various languages(like JavaScript, and Python). 


Postman collections:

A Postman Collection is a group of related API requests saved together in an organized format — like a folder containing API test cases or workflows. Here I will use postman software to create collection and group of requests. You can download latest version of Postman from here.


Why use a collection?

Organize requests for different features or modules

Run them together as a test suite

Add tests for each request

Easily share with teammates

Use in automation tools like Newman or CI/CD pipelines


Let's see how to create a collection?

In my case, I would like to create a collection for Books API which allows to you to reserve a book.

To test any API, there should be a documentation which provides you information how to use that API.

Click on link for Simple Books API documentation.


After downloading and installing the Postman, open the software. You will understand more if you follow video which I have attached below.


GET request:

-> Click on "create new collection" or "+" button on left side and name it (You can choose any collection name).

-> Click on "Add a request" button and choose GET request. Name it (You can choose any request name).

-> Enter the URL that you want to hit in the URL bar. I have put "https://simple-books-api.glitch.me"

-> Enter the endpoint as shown in document. Here I want to know status of API so I entered "/status" as endpoint and choose GET request method.

-> Click on "Send" button which is on right side.

-> You can see the result and status in response body.

The same way you can can create new request to find "List of Books" or "Get a single book" using GET method. For that endpoints are given in documentation.

ree

Environment variable :

Here URL is same for each request so we can save it in environment or collection level as a variable. In my case I want to save URL in environment. Let's see how to do that.



POST request :

Now I would like to submit an order using POST method. You will get an error if you submit order without authentication. So we need to create access token and save it in environment. Then you can access token from environment in POST method. Let's see how to do that.



If you want to generate customername randomly every time, then you can write body for POST request as below. For data driven testing, you can provide sets of data in excel format. In CSV file, I have two column bookID and expected status code.

ree

ree

Also add code snippet in pre-request under scripts method. It will generate random name and save it in a variable generatedCustomerName. You will be able to see same variable in environment as well after you send post request.

ree

In post response, Postman lets you add tests under the Tests tab using JavaScript. These can run automatically after a request is sent. Here you can verify status code, schema, JSON response body etc.


OrderId will be generated once order is created successfully. You can write code as below in post-response under scripts, it will save orderId in environment which you can use later.

    var jsonData = pm.response.json();
    pm.environment.set("orderID", jsonData.orderId);

Patch request:

Patch method allows to update data. In Books API documentation, it allows you to update customer name. You can send patch request as below.

ree

You can skip next request by adding code in pre-request under scripts if order is not created successfully in POST request.

ree

Delete request:

Delete method allows you to delete an existing order. You can send delete request as below.

ree

Run a collection and group of requests:

Running a collection is important for testing end-to-end workflows. You can run many requests at once instead of triggering them manually one by one. Using a data file (CSV/JSON), you can test the same request with multiple sets of input data. You can do regression testing after any changes to ensure nothing broke. Let's see how to run a collection.


Generate Newman Report:


Newman reports provide detailed information about the results of a Postman collection run, including test outcomes, response times.


Prerequisites :

To generate newman html report, you need to download some software.

-> Install Postman on your system. (We already did this)

-> Install nodejs. For that open this website and download latest version.

Open command prompt and run command [node -v]. You should see the installed versions of Node.

-> Install NPM. For that run command [npm install -g newman-reporter-html] on command prompt.

Run command [npm -v] in command prompt. You should see the installed versions of NPM.


Follow below steps to generate newman HTML report.

step 1: Create a collection in Postman with group of requests which we already did.

step 2: Select the collection that you want to export and click on export button. Save it to your local system as JSON file.

ree

step 3: If you have created environment/ global variable, export it and save it to your local system as JSON file.

ree

step4: Open command prompt and run following command to generate HTML report.

newman run "path_to_collection_file" -d "path_to_CSV_file" -e "path_to_environment_file" -r htmlextra --reporter-htmlextra-export "location_where_you_want_to_save_file" 

step5: Open generated report.

Go to folder where you wanted to save report and open it. It will open in browser by default. You will see report as below. It will give you detailed information about test run.

  1. Collection Summary (Number of iterations run, duration of entire run etc)

  2. Overall Test Results (No of tests passed/failed, No of assertions passed/failed etc)

  3. Detailed Breakdown per Request

  4. Request & Response Details

  5. Console Logs (If console.log() used in your test scripts)


ree

Thank you for reading and please give your valuable comments.


Happy Learning :)


+1 (302) 200-8320

NumPy_Ninja_Logo (1).png

Numpy Ninja Inc. 8 The Grn Ste A Dover, DE 19901

© Copyright 2025 by Numpy Ninja Inc.

  • Twitter
  • LinkedIn
bottom of page