Hello. Sorry for the noob question.
How can I search the entire response for a specific value? In this case the value I am using as my assertion would be let’s say “222222”, this has been set as an environment variable (“provId”) in another request and I need to be able to assert that it appears in this second request.
Below is a small snippet of the response I’m working with, the acual response would be much larger and the value “222222” could appear anywhere within.
[
{
“eventId”: “123456”,
“mappings”: [
{
“provider”: “ABC”,
“providerId”: “111111”,
“confidence”: 1.0
}
]
},
{
“eventId”: “246810”,
“mappings”: [
{
“provider”: “ABC”,
“providerId”: “222222”,
“confidence”: 1.0
}
]
},
{
“eventId”: “135791”,
“mappings”: [
{
“provider”: “ABC”,
“providerId”: “333333”,
“confidence”: 1.0
}
]
}
]
I have managed to write a bit of code to check the correct value from the 1st object (below) but I need it to search the whole response.
const body = pm.response.json();
pm.test(“placeholder” + pm.variables.get(“provId”), function() {
pm.response.to.have.jsonBody("[0][mappings].[0][providerId]", pm.variables.get(“provId”) );
});