28 Sep 2024 02:08 AM
Hi,
i have a basic synthetic test for a call api which returns a response.
The response is like:
{
"abc": {
"efg": [
{
"ijk": "hello",
"klm": "bye",
...
How to validate "ijk" is equal to "hello"
i tried this:
var responseBody = response.getResponseBody();
var jsonData = JSON.parse(responseBody);
if (jsonData.abc.efg[0] === "hello") {
return true;
}else{
return false;
}
The test return script_execution_failed
Thank you
Solved! Go to Solution.
28 Sep 2024 12:16 PM
Hi @pseg1984
you can create response validation rule to either pass or fail based on the required fetched response
Regards,
28 Sep 2024 12:57 PM
With Set rule for response validation can i add more than 100 values to validate? do we have to separate by comma?
28 Sep 2024 07:30 PM
Can someone reply to this question?
30 Sep 2024 07:29 AM
If you content can be retrieved by a RegEx so YES.
Just enable the option and put the right RegEx.
28 Sep 2024 12:28 PM
Hi @pseg1984
If you are using rest Api, Go to environment API v2 > Synthetic monitors > PUT.
BR,
28 Sep 2024 03:47 PM
Hi @pseg1984
Very simple SRE and DevOps team are interested in running scripts and Rest APIs instead of exposing User Interfaces for multiple solutions, That's why I've described the second approach as alternative solution, both working as well.
Regards.
Peter.
28 Sep 2024 05:18 PM
Ok so let me check for curl command, it looks interesting for me.
29 Sep 2024 09:17 AM
Hi,
Is it http monitor?
If Yes, please try the bellow option:
29 Sep 2024 06:59 PM
Yes it's HTTP Monitor,
the Set rule for response validation works but i have more than 100 values to valide.