# Using response body in test result

**URL:** <https://community.postman.com/t/using-response-body-in-test-result/29280>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [November 1, 2021, 10:06am UTC](https://community.postman.com/t/using-response-body-in-test-result/29280 "2021-11-01T10:06:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabber](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gabber/32/10225_2.png) [@Gabber](https://community.postman.com/u/Gabber)\
**Post date:** [November 1, 2021, 10:06am UTC](https://community.postman.com/t/using-response-body-in-test-result/29280/1 "2021-11-01T10:06:16Z")

</div>

Hello,

I would like to see some of my response body values in test result. Example response:

```auto
{
    "Id": 10861,
    "Name": "RC_API_45",
    "TypeId": 1
}

```

I can parse ID in Tests tab:

```auto
var jsonData = JSON.parse(responseBody);
pm.environment.set("CustomerId", jsonData["Id"]);

```

Now I`d like to use that value in Test Results log, I already have confirmation of the status code:

```auto
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});

```

And below that I`d like to have sth like this:

> “Customer ID is \_\_\_\_”

How can I make just extracted variable to be visible in TestsResults?

---

<div class="post-metadata">

**Author:** ![cmnazario](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/cmnazario/32/10207_2.png) [@cmnazario](https://community.postman.com/u/cmnazario)\
**Post date:** [November 1, 2021, 1:05pm UTC](https://community.postman.com/t/using-response-body-in-test-result/29280/2 "2021-11-01T13:05:10Z")

</div>

Hello @Gabber  
You can add one more test scenario where you validate if there is the “id” property and in the test name you concatenate with the answer id.

I’ll put an example below:

```auto
pm.test("Customer ID is "+jsonData.id, function() {

    //Validates whether the "id" property exists within the response json
    pm.expect(jsonData).to.have.property('id');

});

```

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![Gabber](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gabber/32/10225_2.png) [@Gabber](https://community.postman.com/u/Gabber)\
**Post date:** [November 2, 2021, 6:39am UTC](https://community.postman.com/t/using-response-body-in-test-result/29280/3 "2021-11-02T06:39:07Z")

</div>

Yes! That was exactly what I was looking for! Thank you @cmnazario !
