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

HTTP monitor script validation key:value

jimmy
Participant

Hello everyone 

I try to make a script who have a json from a web site  and tcheck if the key:value of the json have a différence 

Exemple of json : 

{
"services": [
{
"available": true,
"operation": "Communes",
"responsecode": 200,
"service": "Commune Service"
},
{
"available": true,
"operation": "Annexe Groupe",
"responsecode": 200,
"service": "Documents Service"
},
{
"available": false,
"operation": "Disponibilité",
"responsecode": 500,
"service": "Service"
},
{
"available": true,
"operation": "Verifier",
"responsecode": 200,
"service": "Plateforme"
},
{
"available": true,
"operation": "Personne",
"responsecode": 200,
"service": "Personne Service"
},
{
"available": true,
"operation": "Recherche",
"responsecode": 200,
"service": "Contrat Service"
}
]
});

 

My script : 

 

var responseBody = response.getResponseBody();
var jsonData = JSON.parse(responseBody);
api.info(jsonData);

parsedJson["services"].forEach(function (singlestatus, allstatus)
if(singlestatus["operation"] === "Obtenir Communes" && singlestatus["available"] === true) {

api.fail("not good");
}
else if (singlestatus["operation"] === "Obtenir Communes" && singlestatus["available"] === true) {

api.fail("not good");

}
else if (singlestatus["operation"] === "Obtenir Communes" && singlestatus["available"] === true) {
api.fail("not good");
}
else if (singlestatus["operation"] === "Obtenir Communes" && singlestatus["available"] === true) {
api.fail("not good");
}
else if (singlestatus["operation"] === "Obtenir Communes" && singlestatus["available"] === true) {
api.fail("not good");
}
else if (singlestatus["operation"] === "Obtenir Communes" && singlestatus["available"] === true) {

}

 

 

But is failed i d'ont  how i can debug it and see the output of 

api.info(jsonData);



 

Thx for your help 

1 REPLY 1

Super
Contributor

Are you sure that is not EOF error in your script? 

Which string number mark as error?

Featured Posts