# How to display actual response values in test results

**URL:** <https://community.postman.com/t/how-to-display-actual-response-values-in-test-results/51848>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [September 15, 2023, 12:35pm UTC](https://community.postman.com/t/how-to-display-actual-response-values-in-test-results/51848 "2023-09-15T12:35:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgreen65](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@dgreen65](https://community.postman.com/u/dgreen65)\
**Post date:** [September 15, 2023, 12:35pm UTC](https://community.postman.com/t/how-to-display-actual-response-values-in-test-results/51848/1 "2023-09-15T12:35:41Z")

</div>

Hi all,

I am attempting to display an actual value from an API call ‘Body response’ and also a ‘Headers’ item in test results.

I can interrogate both by const response = pm.response.json() and pm.response.headers.get… and display them using console.log but is there a way to display the actual values in test results ?

For example, I might get number of items = 4 in the body response. I can get the value of ‘4’ printed in console.log but how do I get a test result to display ‘4’. Similarly, a ‘correlation id’ is displayed in ‘Headers’, can I get this displayed in test results, not just in console.log.

Thanks in advance.

---

<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:** [September 15, 2023, 1:44pm UTC](https://community.postman.com/t/how-to-display-actual-response-values-in-test-results/51848/2 "2023-09-15T13:44:55Z")

</div>

Hey @dgreen65 👋

Welcome back to the Postman Community! :postman:

Could you provide an example of the response body and the test that you have in place so far?

---

<div class="post-metadata">

**Author:** ![dgreen65](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@dgreen65](https://community.postman.com/u/dgreen65)\
**Post date:** [September 19, 2023, 6:40am UTC](https://community.postman.com/t/how-to-display-actual-response-values-in-test-results/51848/3 "2023-09-19T06:40:16Z")

</div>

Hi Danny, to give a bit of background, I have a test collection (launched manually) which includes over 100 tests.

At the end of the run I need to export the results which, as they only include high level information (by default), don’t include some data I need such as ‘header’ information.

If I can get the data within the test results themselves then it would be displayed in the report/export.

A test could just be a simple GET call resulting in total number response, the first part of the body response being;

```auto
{
      "resultCount": 1; etc
} 

```

The same test will have an ID within the ‘Headers’ tab;

```auto
Key: Request-Id Value: xxxxxxxxxxxxxxxxxxxxxxx

```

I can parse the responses, confirm the resultcount is a number etc etc and I can also convert the request-id to an environment variable.

What I wan to be able to do is DISPLAY both results in test results so they will then be included in the test run export at the end of the run.

> e.g result count =, request id =

Hope that makes sense 🙂

Thanks.

---

<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:** [September 19, 2023, 7:04am UTC](https://community.postman.com/t/how-to-display-actual-response-values-in-test-results/51848/4 "2023-09-19T07:04:01Z")

</div>

Hey @dgreen65,

So you can you [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) in the actual test name to display different pieces of information.

This is a dummy example but this would be resolving the value from the response body and using that in the test name string.

```auto
const id = pm.response.json().id
pm.test(`Check for ID - ID equals ${id}`)... 

```

Is that the type of thing that you’re after?

---

<div class="post-metadata">

**Author:** ![dgreen65](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@dgreen65](https://community.postman.com/u/dgreen65)\
**Post date:** [September 19, 2023, 7:17am UTC](https://community.postman.com/t/how-to-display-actual-response-values-in-test-results/51848/5 "2023-09-19T07:17:34Z")

</div>

Hi Danny, thanks for the response, I just need the actual results displaying within the Test Results tab not just confirmtaion that a result exists e.g. PASS Result count = 1 in the above example

I can get both values to be displayed in the console.log so I would have thought the same result could be displayed in the test results themselves, that’s my logic anyway 🙂

---

<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:** [September 19, 2023, 7:20am UTC](https://community.postman.com/t/how-to-display-actual-response-values-in-test-results/51848/6 "2023-09-19T07:20:36Z")

</div>

That’s what I was explaining, did you try what I suggested? 😓

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

You would see that name in the tests tab with the values from the response or a variable or anything else.

Can you show me what you get when you try that out on your side please?

---

<div class="post-metadata">

**Author:** ![dgreen65](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@dgreen65](https://community.postman.com/u/dgreen65)\
**Post date:** [September 19, 2023, 8:32am UTC](https://community.postman.com/t/how-to-display-actual-response-values-in-test-results/51848/7 "2023-09-19T08:32:13Z")

</div>

Sorry, I’m no postma/java expert so I didn;t get enough of a hint from your reply 🙂

It’s working great thanks for displaying the result count using;

const count = pm.response.json().resultCount  
pm.test (`Result count equals ${count]`)

I’m just trying to work out gtting the same result from the header tab using pm.response.headers.get… but not quite cracked it yet

Thanks for your guidance 🙂

---

<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:** [September 19, 2023, 8:39am UTC](https://community.postman.com/t/how-to-display-actual-response-values-in-test-results/51848/8 "2023-09-19T08:39:37Z")

</div>

Glad you have something working so you can see how it all comes together. 🏆

You could get the header value by doing something like this:

```auto
let RequestId = pm.response.headers.get('Request-Id');

```

More information on the `pm.*` set of APIs can be found here:

> **[Postman JavaScript reference | Postman Learning Center](https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/)**
>
> Postman JavaScript reference: documentation for Postman, the collaboration platform for API development. Create better APIs—faster.

---

<div class="post-metadata">

**Author:** ![dgreen65](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@dgreen65](https://community.postman.com/u/dgreen65)\
**Post date:** [September 19, 2023, 8:48am UTC](https://community.postman.com/t/how-to-display-actual-response-values-in-test-results/51848/9 "2023-09-19T08:48:10Z")

</div>

Cheers, thanks for your help Danny.

---

<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:** [September 19, 2023, 8:49am UTC](https://community.postman.com/t/how-to-display-actual-response-values-in-test-results/51848/10 "2023-09-19T08:49:52Z")

</div>


