# Check attributes get response

**URL:** <https://community.postman.com/t/check-attributes-get-response/22023>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [March 29, 2021, 7:32am UTC](https://community.postman.com/t/check-attributes-get-response/22023 "2021-03-29T07:32:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alejandroescribano](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@alejandroescribano](https://community.postman.com/u/alejandroescribano)\
**Post date:** [March 29, 2021, 7:32am UTC](https://community.postman.com/t/check-attributes-get-response/22023/1 "2021-03-29T07:32:56Z")

</div>

Hello, i’m trying to check the value of an attribute returned by get request. I want to check that the status is correct, and versión.  
For example:  
{

```
"id": "XXXXX",

"statuses": [

    {

        "version": 1,

        "user": "AAAAA",

        "department": "BBBBB",

        "status": "CCCCC",

        "action": "DDDDD",

        "date": "2021-03-29 07:21:21 +0000",

        "last": false

    },

    {

        "version": 2,

        "user": "EEEEE",

        "department": "FFFFFF",

        "status": "JJJJJ",

        "action": "KKKKK",

        "date": "2021-03-29 07:22:46 +0000",

        "last": true

```

}  
]

}

---

<div class="post-metadata">

**Author:** ![thefierycoder](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@thefierycoder](https://community.postman.com/u/thefierycoder)\
**Post date:** [March 29, 2021, 7:50am UTC](https://community.postman.com/t/check-attributes-get-response/22023/2 "2021-03-29T07:50:26Z")

</div>

Hello there,  
Welcome to the community

I didn’t understand your question properly.  
If you want to access version and status.  
You can access them like this.  
First save the response in the test script.  
`var response = pm.response.json();`

then

```auto
    response.statuses.forEach(status => {
      const version = status.version;
      const stat = status.status;
    )}

```

I hope this will help you.  
If you have any other questions, feel free to ask.

---

<div class="post-metadata">

**Author:** ![alejandroescribano](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@alejandroescribano](https://community.postman.com/u/alejandroescribano)\
**Post date:** [March 29, 2021, 9:15am UTC](https://community.postman.com/t/check-attributes-get-response/22023/3 "2021-03-29T09:15:58Z")

</div>

> [@thefierycoder](#):
>
> `onse.statuses.forEach`

I want to check the value, for example that the response contains the version 1 and 2, and the status X and Y.

Thansk for all!

---

<div class="post-metadata">

**Author:** ![jency.stella19](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jency.stella19/32/16633_2.png) [@jency.stella19](https://community.postman.com/u/jency.stella19)\
**Post date:** [March 29, 2021, 10:10am UTC](https://community.postman.com/t/check-attributes-get-response/22023/4 "2021-03-29T10:10:50Z")

</div>

Hi @alejandroescribano similar to @thefierycoder code you can try to add the below assertion to get the version and status

> for (var i=0; i\<resp.statuses.length; i++)  
> {
> 
> ```
> pm.test("Checking Version" , function () 
> {
> pm.expect(resp.statuses[i].version).to.be.oneOf([1,2]);
> });  
> 
> pm.test("Checking Status" , function () 
> {
> pm.expect(resp.statuses[i].status).to.be.oneOf(["CCCCC","JJJJJ"]);
> });  
> 
> ```
> 
> }

You can view the [Chai Assertion Library](https://www.chaijs.com/api/assert/) to view more assertions syntax to get your work done.

---

<div class="post-metadata">

**Author:** ![alejandroescribano](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@alejandroescribano](https://community.postman.com/u/alejandroescribano)\
**Post date:** [March 29, 2021, 11:54am UTC](https://community.postman.com/t/check-attributes-get-response/22023/5 "2021-03-29T11:54:46Z")

</div>

> [@jency.stella19](#):
>
> `pm.expect(resp.statuses[i].version).to.be.oneOf([1,2]);`

YES! I can do it! Thanks, very much.
