12 May 2022 02:41 PM
Hello
I would like to parse a json file with an http monitor this is my json
{ "services": [ { "available": true, "operation": "Communes", "responsecode": 200, "service": "Commune Service" }, { "available": true, "operation": "Annexe Groupe", "responsecode": 200, "service": "Documents Service" }, { "available": false, "operation": "Obtenir Disponibilité", "responsecode": 500, "service": "Utilisateurs Service" }, { "available": true, "operation": "Verifier Cheque", "responsecode": 200, "service": "Platefor" }, { "available": true, "operation": "Personne", "responsecode": 200, "service": "Personne" }, { "available": true, "operation": "Recherche", "responsecode": 200, "service": "Contrat" } ] }
I would like to know how I could get the status
"available": true,
and make a warning if is set by false
thx for help !
Solved! Go to Solution.
16 May 2022 09:54 AM
Is it a specific service you are interested in or do you need to know for each service?
30 May 2022 11:36 AM
Hi thx for answer me !
Is for each service
06 Jun 2022 12:30 PM
You can get the response and parse as json like this:
var responseBody = response.getResponseBody();
var jsonData = JSON.parse(responseBody);
You will then need to iterate through each service checking for the status. You can then either use api.fail() directly to fail the monitor as soon as you find a service that is not available or you can set a variable and then check it once you have checked all the services and then fail the monitor with a message that states which services were not available.