24 Aug 2022 01:58 PM - last edited on 25 Aug 2022 09:25 AM by MaciejNeumann
I'm currently working on an HTTP monitor where I don't know how to validate the JSON response.
It is a status.io endpoint that I would like to query, but the JSON response contains more info than I need. Is it possible to isolate two objects with post-execution scripts prior to validation? Let's say I wanted to validate on Voice DK & Agent application status.
If anyone could point me in the right direction it would be much appreciated 😊
Endpoint:
https://api.status.io/1.0/status/58207f2bf02471510e000303
Solved! Go to Solution.
24 Aug 2022 05:33 PM
You will need to parse the json with javascript code.
Example:
{
"totalCount": 3,
"nextPageKey": null,
"resolution": "1m",
}
body = response.getResponseBody();
obj = JSON.parse(body);
totalCount = obj.totalCount;
api.setValue("totalCount", totalCount);
if (totalCount == 0) {
api.fail("Total Count is null");
} else {
api.info("Total Count is not null");
}
You just need to proper parse the result json you get from the status page to get the proper field for validation.
Regards