cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HTTP monitor: How do I validate on only parts of a JSON response?

rsmsdk
Helper

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

1 REPLY 1

dannemca
DynaMight Guru
DynaMight Guru

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

Site Reliability Engineer @ Kyndryl

Featured Posts