Test Array for Object

Trying to implement a test to validate an object/property exists in the array. If it doesn’t exist I would like to have it run another request. Is this possible?

Here is a small snippet of the response I am working with. Some responses will return:

<Target>
            <ComputerID>10278461</ComputerID>

Where as others may return:

<Target>
            <CustomRelevance>Group contains 123</CustomRelevance>

Essentially if ComputerID doesn’t exist then I would like for a different request to be issued to accommodate. I assume setnextrequest would be the clause to use if ComputerID doesn’t exist?

Any assistance is greatly appreciated.

I am looking for something along the lines of:

pm.test('ComputerID Object Exists', function() {
  pm.expect(responseJson.BES.MultipleActionGroup.Target).to.have.property('ComputerID') })
{else 
    postman.setNextRequest()}

Hi @austin4778, does this post help answer your question?

Hi!!! I have a array response as below, which will change dynamically with addition of data.
I have a value set in Environment variable from a POST call, and how do I search that value in the GET request. So I need to parse the array objects and stop at the value which is matching the environment variable value
[
{
“id”: “0cb0e4cf-0bcd-4234-b84d-839bbc1c823e”,
“name”: “4gclinical Data Source”,
“nameKey”: “SecurityDataSource”
},
{
“id”: “e0a7ac43-1713-4193-b846-3ff379ef8b95”,
“name”: “a corporis repudiandae”,
“nameKey”: “facilis”
},
{
“id”: “b1004fd5-446d-497c-96ff-8c06e9d1bd43”,
“name”: “ab assumenda accusamus”,
“nameKey”: “{{randomLoremWord}}”
},
{
“id”: “4e92809e-acb9-4ed0-b64b-a399554a7c7d”,
“name”: “adipisci sunt molestiae”,
“nameKey”: “et”
},
{
“id”: “d80d72a2-8f5a-4e96-b05a-f737ffdb2bc8”,
“name”: “adipisci voluptas et”,
“nameKey”: “quas”
},
{
“id”: “92320fcd-22b9-48c7-8d71-996d933190d4”,
“name”: “alias dignissimos minus”,
“nameKey”: “sint”
},
{
“id”: “bedc2f46-ef6e-4c13-bd81-8ff007afa5a4”,
“name”: “alias voluptas sed”,
“nameKey”: “consectetur”
},
{
“id”: “1fcd7cf2-eb66-4272-ba26-408233bfc845”,
“name”: “AM enterprise data source”,
“nameKey”: “amenterDataSource”
},
{
“id”: “91b1f5ec-b1c2-4748-a2ef-0e0206e8e7fc”,
“name”: “Anti-Slavery”,
“nameKey”: “DataSourceCategory.Anti-Slavery”
},
{
“id”: “a103d33a-9bd3-4780-8c90-9e3ef9ac8aff”,
“name”: “Assessment1”,
“nameKey”: “AssessmentNameKey”
},
{
“id”: “9552e93c-632b-4465-8dbe-b8a7081177dd”,
“name”: “aut est distinctio”,
“nameKey”: “voluptas”
},
{
“id”: “5c4621dc-5245-4496-a174-03f1692b13ab”,
“name”: “c-afbnyci”,
“nameKey”: “c-afbnyci”
},
{
“id”: “ec645c4b-5fb5-4c57-929f-7dfc3ba0c6fb”,
“name”: “c-cmrwcmm”,
“nameKey”: “c-cmrwcmm”
},
{
“id”: “2191cd32-6c41-4366-b076-47d761475a4c”,
“name”: “c-nkkdpkw”,
“nameKey”: “c-nkkdpkw”
},
{
“id”: “3c332983-6101-42b5-a1f0-ae9260289b84”,
“name”: “c-nznmffl”,
“nameKey”: “c-nznmffl”
},
{
“id”: “bc4bff4e-8fac-4231-944c-6798c338cb36”,
“name”: “C-rfwtane”,
“nameKey”: “C-rfwtane”
},
{…}
]

The array would keep on increasing as and when I add value using post call. Please help me out with how to map a value which is set in the environment variable from POST call to search in GET call.