# How to capture response body data in Newman result report

**URL:** <https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944>\
**Category:** Help Hub\
**Created:** [February 15, 2018, 12:20pm UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944 "2018-02-15T12:20:55Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![rmlira](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/rmlira/32/232_2.png) [@rmlira](https://community.postman.com/u/rmlira)\
**Post date:** [April 13, 2018, 6:28pm UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/21 "2018-04-13T18:28:00Z")

</div>

I add some code to javascript as follows:

```
	<script type="text/javascript">
    "use strict";

window.onload = function () {

  // hides all blocks of response
  var allItems = document.querySelectorAll('[class*=iteration-]');
  allItems.forEach(function(elem){
    elem.style.display = 'none';
  });

  {{#with summary}} {{#with stats}}
  let totalIterations = {{iterations.total}};
  {{/with}} {{/with}}

  let menu = document.querySelector('#execution-menu .nav');

  for(var i = 0; i < totalIterations; i++)
  {
    let li = document.createElement('li');
    li.appendChild(document.createTextNode('Iteration - ' + i));
    li.setAttribute('id', 'iteration-' + i);
    li.classList.add("custom-tab");

    li.addEventListener('click', function() {

      let allItems = document.querySelectorAll('[class*=iteration-]');
      allItems.forEach(function(elem) {
        elem.style.display = 'none';
      })

      let allMenus = document.querySelectorAll('[id*=iteration-');
      allMenus.forEach(function(elem){
        elem.style.borderBottom = 'none';
      })

      this.style.borderBottom = 'solid 1px #032a33';

      let items = document.querySelectorAll("." + this.id);
      items.forEach(function(elem) {
        elem.style.display = elem.style.display == 'block' ? 'none' : 'block';
      })
    });

    menu.appendChild(li);
  }

    //shows first tab data
  document.getElementById('iteration-0').click();
}</script>

```

and add this css code:

```
.custom-tab {
            padding: 10px 15px;
            margin-right: 3px;
            border: solid 1px #fff;
            border-bottom: none;
            cursor:pointer;
        }
        .custom-tab .active {
            border-bottom:solid 1px #032a33;
        }
        #execution-data {
            padding: 10px;
            border: solid 1px #fff;
            border-top: none;
        }

```

Now it looks like this:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/6/9/69a72c03181f8ca9b8ffcc0c9b30343c3205f539.png)

I upload the files to you… can you test again please?

---

<div class="post-metadata">

**Author:** ![bhanu.princein](https://avatars.discourse-cdn.com/v4/letter/b/ce73a5/32.png) [@bhanu.princein](https://community.postman.com/u/bhanu.princein)\
**Post date:** [May 24, 2018, 3:39am UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/22 "2018-05-24T03:39:45Z")

</div>

@rmlira …Hi I have been trying to generate custom report for my project. I am using same hbs file as gopal above. I am getting all layout as is except the color grading (styles). What I am missing here?

---

<div class="post-metadata">

**Author:** ![edwinboy](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/edwinboy/32/666_2.png) [@edwinboy](https://community.postman.com/u/edwinboy)\
**Post date:** [June 11, 2018, 7:07pm UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/23 "2018-06-11T19:07:23Z")

</div>

hi Renan,

Could you please upload the latest .hbs file and index.js file or send to my email. It would be appreciated if you could help me implement the your custom reports. It looks great and precise.

---

<div class="post-metadata">

**Author:** ![charmee2811](https://avatars.discourse-cdn.com/v4/letter/c/eb9ed0/32.png) [@charmee2811](https://community.postman.com/u/charmee2811)\
**Post date:** [June 20, 2018, 1:51pm UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/24 "2018-06-20T13:51:04Z")

</div>

Hi,  
your reports looks perfect could you please help me with customise template your index file

---

<div class="post-metadata">

**Author:** ![vpnsingh](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@vpnsingh](https://community.postman.com/u/vpnsingh)\
**Post date:** [June 20, 2018, 7:15pm UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/25 "2018-06-20T19:15:53Z")

</div>

Hi @rmlira  
your reports looks perfect.  
could you please help me with customise template . i want if {{cumulativeTests.failed}} \>0 then parent panel-heading color should be in red if {{cumulativeTests.failed}} = 0 panel-heading color should be green.  
please see attached image.

 ![Newman_report](https://us1.discourse-cdn.com/getpostman/original/3X/5/b/5bc5cb1bcda04eb962a17da36641213ab09b54d1.png)

my Costomized template.hbs code below.

#### Requests

```
{{#each aggregations}}
    {{#if parent.name}}
    <div class="panel-heading tego-bg-green" id="collapse-folder-{{parent.id}}-{{parent.iteration}}" role="tablist" aria-multiselectable="true">
       
		<div role="tab" id="folderHead-{{parent.id}}">
            <h4 style="font-size: 18px;" class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#folderData-{{parent.id}}-{{parent.iteration}}" aria-controls="collapseOne"><strong>{{parent.name}}</strong></a></h4>
        </div>
        <br/>
        <div id="folderData-{{parent.id}}-{{parent.iteration}}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="folderHead-{{parent.id}}-{{parent.iteration}}">
        {{> aggregations}}
        </div>
    </div>
    {{else}}
    {{> aggregations}}
    {{/if}}
{{/each}}

```

{{#\*inline “aggregations”}}  
{{#each executions}}

  

  

  

#### [{{item.name}}](#requestData-{{item.id}}-{{cursor.iteration}})
  

```
            <div id="requestData-{{item.id}}-{{cursor.iteration}}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="requestHead-{{item.id}}-{{cursor.iteration}}">
                <div class="panel-body">
                    {{#with request}}
                        {{#if description.content}}
                            <div class="col-md-4">Description</div><div class="col-md-8" style="white-space: pre-wrap;">{{description.content}}</div>
                            <div class="col-md-12">&nbsp;</div>
                        {{/if}}

                        <div class="col-md-4">Method</div><div class="col-md-8">{{method}}</div>
                        <div class="col-md-4">URL</div><div class="col-md-8"><a href="{{url}}" target="_blank">{{url}}</a></div>
                    {{/with}}						
					<div class="col-md-4">Response Body</div><div class="col-md-8">{{response.body}} </div>
					<div {word-wrap: break-word;}</div>
                    <div class="col-md-12">&nbsp;</div>
                    <div class="col-md-4">Mean time per request</div><div class="col-md-8">{{mean.time}}</div><br/>
                    <div class="col-md-4">Mean size per request</div><div class="col-md-8">{{mean.size}}</div><br/>

                    <div class="col-md-12">&nbsp;</div>
                    <br/><div class="col-md-4">Total passed tests</div><div class="col-md-8">{{cumulativeTests.passed}}</div>
                    <div class="col-md-4">Total failed tests</div><div class="col-md-8">{{cumulativeTests.failed}}</div><br/>

                    <div class="col-md-12">&nbsp;</div>
                    <br/><div class="col-md-4">Status code</div><div class="col-md-8">{{response.code}}</div><br/>

                    {{#if assertions.length}}
                        <div class="col-md-12">&nbsp;</div>
                        <div class="col-md-4">Tests</div>

                        <div class="col-md-8">
                            <table class="table table-responsive table-condensed">
                                <thead><tr><th>Name</th><th>Pass count</th><th>Fail count</th></tr></thead>									
                                <tbody>{{#each assertions}}<tr><td>{{this.name}}</td><td>{{this.passed}} <td>{{this.failed}}</td> </tr>{{/each}}</tbody>
                            </table>
                        </div>
                    {{/if}}
					
                </div>
            </div>
        </div>
    </div>
{{/each}}

```

{{/inline}}

please help me.  
Thanks,  
Vipin

---

<div class="post-metadata">

**Author:** ![VADIVEL\_M](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@VADIVEL\_M](https://community.postman.com/u/VADIVEL_M)\
**Post date:** [July 16, 2018, 9:59am UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/26 "2018-07-16T09:59:52Z")

</div>

@rmlira: i have tried with these changes but each iteration has same result.  
Expectation:  
iteration tab1  
test1  
test2  
iteration tab2  
test1  
test2

Actual:  
iteration tab1  
test1  
test2  
test1  
test2  
iteration tab2  
test1  
test2  
test1  
test2

i have upadated index.js, hbs file. Could you please help me?

---

<div class="post-metadata">

**Author:** ![Kal](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@Kal](https://community.postman.com/u/Kal)\
**Post date:** [August 7, 2018, 3:12pm UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/27 "2018-08-07T15:12:20Z")

</div>

Hi there  
I have tested this one with your latest index.js and jsonreportPrettyWithTabChanges.hbs which are available in gDrive but its throwing an error like below.  
Could you please take a look?

cmd line: \>newman run C:\Users\kkaku\Documents\Fulfillment\Framework\z\_SetNextRequest.postman\_collection.json --folder “folder1” -r html,cli,junit -g C:\Users\kkaku\Documents\Fulfillment\Framework\MyWorkspace.postman\_globals -e C:\Users\kkaku\Documents\Fulfillment\Framework\Cert.postman\_environment.json --reporter-html-template C:\Users\kkaku\Documents\Fulfillment\Framework\jsonreportPrettyWithTabChanges.hbs

Error:  
C:\Users\kkaku\node\_modules\handlebars\dist\cjs\handlebars\compiler\parser.js:268  
throw new Error(str);  
^

Error: Parse error on line 506:  
};  
----------------------^  
Expecting ‘OPEN\_INVERSE\_CHAIN’, ‘INVERSE’, ‘OPEN\_ENDBLOCK’, got ‘EOF’  
at Parser.parseError (C:\Users\kkaku\node\_modules\handlebars\dist\cjs\handlebars\compiler\parser.js:268:19)  
at Parser.parse (C:\Users\kkaku\node\_modules\handlebars\dist\cjs\handlebars\compiler\parser.js:337:30)  
at HandlebarsEnvironment.parse (C:\Users\kkaku\node\_modules\handlebars\dist\cjs\handlebars\compiler\base.js:46:43)  
at compileInput (C:\Users\kkaku\node\_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js:515:19)  
at ret (C:\Users\kkaku\node\_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js:524:18)  
at EventEmitter. (C:\Users\kkaku\node\_modules\newman\lib\reporters\html\index.js:157:22)  
at EventEmitter.emit (C:\Users\kkaku\node\_modules\eventemitter3\index.js:203:33)  
at done (C:\Users\kkaku\node\_modules\newman\lib\run\index.js:260:29)  
at C:\Users\kkaku\node\_modules\postman-runtime\lib\backpack\index.js:56:34  
at PostmanCollectionRun.\_process (C:\Users\kkaku\node\_modules\postman-runtime\lib\runner\run.js:161:13)  
at PostmanCollectionRun. (C:\Users\kkaku\node\_modules\postman-runtime\lib\runner\run.js:166:76)  
at ontimeout (timers.js:482:11)  
at tryOnTimeout (timers.js:317:5)  
at Timer.listOnTimeout (timers.js:277:5)

---

<div class="post-metadata">

**Author:** ![Kal](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@Kal](https://community.postman.com/u/Kal)\
**Post date:** [August 7, 2018, 3:19pm UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/28 "2018-08-07T15:19:26Z")

</div>

Hi Gopi,

I was trying to use your gDrive files and modified ones by @rmlira to customize the newman report, but it was throwing some errors on cmd prompt(i mentioned error log to @rmilra in this post, i dont know what was causing issue. Could you or @rmilra please help on this.

Thank you!

---

<div class="post-metadata">

**Author:** ![yamini.goyal](https://avatars.discourse-cdn.com/v4/letter/y/9d8465/32.png) [@yamini.goyal](https://community.postman.com/u/yamini.goyal)\
**Post date:** [October 5, 2018, 12:39pm UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/29 "2018-10-05T12:39:32Z")

</div>

Hi I need your help to generate report in html

---

<div class="post-metadata">

**Author:** ![slaven.antic](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@slaven.antic](https://community.postman.com/u/slaven.antic)\
**Post date:** [November 19, 2018, 9:20am UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/30 "2018-11-19T09:20:48Z")

</div>

Hi,

I am using newman 4.2.2. version and have tried this modification of template to include every iteration request in different “collapse-request-item-index”. As far as I have understood the indications from this thread the different requests should appear in the report when modifying the template. In my case, I can see the response body only. I don’t see different request for every iteration. It remains on the last call this time.

I haven’t change the index.html. My installation path to html-reporter is: C:\Users[user]\AppData\Roaming\npm\node\_modules\newman-reporter-html\lib

Part of the template that I have modified:  
{{#\*inline “aggregations”}}  
{{#each executions}}

  

  

  

#### [{{item.name}}](#requestData-%7B%7Bitem.id%7D%7D-%7B%7B@index%7D%7D)
  

```
            <div id="requestData-{{item.id}}-{{@index}}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="requestHead-{{item.id}}-{{@index}}">
                <div class="panel-body">
                    {{#with request}}
                        {{#if description.content}}
                            <div class="col-md-4">Description</div><div class="col-md-8" style="white-space: pre-wrap;">{{description.content}}</div>
                            <div class="col-md-12">&nbsp;</div>
                        {{/if}}

                        <div class="col-md-4">Method</div><div class="col-md-8">{{method}}</div>
                        <div class="col-md-4">URL</div><div class="col-md-8"><a href="{{url}}" target="_blank">{{url}}</a></div>
                    {{/with}}
                    <div class="col-md-4">Response Body</div><div class="col-md-8">{{response.body}}</div>
                    <div class="col-md-12">&nbsp;</div>

```

Can you please help me understand if I am doing anything wrong?

---

<div class="post-metadata">

**Author:** ![slaven.antic](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@slaven.antic](https://community.postman.com/u/slaven.antic)\
**Post date:** [November 19, 2018, 9:27am UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/31 "2018-11-19T09:27:27Z")

</div>

I have done these same steps and I don’t see each iteration request. Just the last one.  
@rmlira can you please tell me if there is something else that I need to add or change?

---

<div class="post-metadata">

**Author:** ![kirankumar1249](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@kirankumar1249](https://community.postman.com/u/kirankumar1249)\
**Post date:** [January 7, 2019, 7:20am UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/32 "2019-01-07T07:20:32Z")

</div>

Hi Rmlira,

Please share files for custom reports…

---

<div class="post-metadata">

**Author:** ![kirankumar1249](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@kirankumar1249](https://community.postman.com/u/kirankumar1249)\
**Post date:** [January 7, 2019, 7:22am UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/33 "2019-01-07T07:22:33Z")

</div>

Hi @gopikrishna4595 please send the custom reports of Iterations

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [January 7, 2019, 12:55pm UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/34 "2019-01-07T12:55:16Z")

</div>

I’ve created this reporter that will show non aggregated results, skipped tests and so more things if that’s of interest to people.

No need to manually change you’re files etc.

> **[newman-reporter-htmlextra](https://www.npmjs.com/package/newman-reporter-htmlextra)**
>
> A newman reporter with added handlebars helpers and separated request iterations. Latest version: 1.22.11, last published: a year ago. Start using newman-reporter-htmlextra in your project by running \`npm i newman-reporter-htmlextra\`. There are 13...

If anyone needs anything else adding to the reporter, I can look at doing this for people…As long as it’s possible. 😁

---

<div class="post-metadata">

**Author:** ![kirankumar1249](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@kirankumar1249](https://community.postman.com/u/kirankumar1249)\
**Post date:** [January 8, 2019, 5:48am UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/35 "2019-01-08T05:48:09Z")

</div>

Hello @danny-dainton

Thank a lot for your support… I need to capture request body of each request and each Iteration…please help on this…

Thank you again buddy…🙂

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [January 8, 2019, 6:16am UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/36 "2019-01-08T06:16:29Z")

</div>

Hey,

Thanks for the support. The information is there in the overall summary object but I just didn’t actively expose it on the report templates.

You can add this to the template yourself for now:

```
{{#with request}} 
{{#if body.raw}}
 <pre>{{body.raw}}</pre>
 {{/if}} 
{{/with}}

```

It would be something like that, placed in the relevant area of the template. That will show the request body, if the request has one.

I will update my template later today to add this section in but if you want to experiment now and not wait, you could manually update it from your side.

It’s difficult to create a generic template that covers everyones individual usecase with their own context.

I would absolutely recommend trying to create your own personal template to use with the reporter and then you have full control over which pieces of data you either expose or don’t expose.

---

<div class="post-metadata">

**Author:** ![kirankumar1249](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@kirankumar1249](https://community.postman.com/u/kirankumar1249)\
**Post date:** [January 8, 2019, 6:38am UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/37 "2019-01-08T06:38:59Z")

</div>

Hello @danny-dainton

Thank You so much … once done report template … please share it

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [January 8, 2019, 7:09am UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/38 "2019-01-08T07:09:44Z")

</div>

Create a temporary template yourself, it’s so much quicker. 😁

Waiting for me to add something is just a waste of your time if you require something now.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [January 8, 2019, 12:43pm UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/39 "2019-01-08T12:43:54Z")

</div>

I’ve added the request body, if the request has one, to the default template and the dashboard style template.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/b/0/b0bb9c9e17313d12328ad3b499ed3c171ab49cb5.png)

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/6/a/6addc014d438a0dc0cfe110a26cbaed5d1e1f44a.png)

These changes can be found on version 1.2.3 of the NPM package or you could also just grab the file from Github.

Is this what you required on the report or something else?

---

<div class="post-metadata">

**Author:** ![kirankumar1249](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@kirankumar1249](https://community.postman.com/u/kirankumar1249)\
**Post date:** [January 8, 2019, 1:23pm UTC](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944/40 "2019-01-08T13:23:53Z")

</div>

Hi @danny-dainton,

Thank you Bro,

Please share files or send me link of shared drive.

[Previous page](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944.md?page=1)

[Next page](https://community.postman.com/t/how-to-capture-response-body-data-in-newman-result-report/944.md?page=3)
