# How to grab variable from one API that is within a nested Array response body?

**URL:** <https://community.postman.com/t/how-to-grab-variable-from-one-api-that-is-within-a-nested-array-response-body/16758>\
**Category:** Help Hub\
**Created:** [October 14, 2020, 4:06pm UTC](https://community.postman.com/t/how-to-grab-variable-from-one-api-that-is-within-a-nested-array-response-body/16758 "2020-10-14T16:06:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shahbaz.shiekhqa](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@shahbaz.shiekhqa](https://community.postman.com/u/shahbaz.shiekhqa)\
**Post date:** [October 14, 2020, 4:06pm UTC](https://community.postman.com/t/how-to-grab-variable-from-one-api-that-is-within-a-nested-array-response-body/16758/1 "2020-10-14T16:06:13Z")

</div>

How to grab the contentID and content title add it within an array and have it used in the URL of API 2

if i use the code below for section title and sectionid it is working because it is not in an nested array but for the contentid and contenttitle it is not working as it is in a nested array.

API 1 test tab i have:  
for (i = 0; i \< resultCount; i++) {

var id = jsonData[i].contents[0].contentId;

var modelString = jsonData[i].contents[0].contentTitle;

console.log(id)

console.log(modelString)

if (modelString.includes(“APIAUTOMATIONcontent”) || modelString.includes(“Testcontent”) || modelString.includes(“{{POST-NewSlide}}”) || modelString.includes(“stringcontent”)) {

```auto
hasDelete.push(id);

// (id) - this creates an integer (int)

// "announcementId": id, (creating object)

// "hasDelete": modelString.includes("Delete") || modelString.includes("Test")

// });

```

} else {

```auto
doesntHaveDelete.push(id)

// "announcementId": id

// });

```

}

}

// Check that each object in response contained keyword and length matches from test

pm.test( `Number of Content that has APIAUTOMATIONcontent or Test ready to be deleted = ${hasDelete.length} out of Total ${resultCount}` , function() {

console.log(hasDelete);

console.log(doesntHaveDelete);

pm.expect(hasDelete.length);

});

pm.collectionVariables.set(‘deletesections’, JSON.stringify(hasDelete));

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