Reputation: 3
hello there can somebody help me, I am validating the response of an api, I need to validate that at least one of the 3 tests is true, this api performs 3 requests
var dataStr = prev.getResponseDataAsString();
var data = JSON.parse(dataStr);
if(data.IsSuccessful == true) {
AssertionResult.setFailure(false);
}
else {
AssertionResult.setFailure(true);
AssertionResult.setFailureMessage('fail');
}
ResponseApi Post
{
"IsSuccessful":false,
"IsError":true,
"ErrorMessage":"Error"
}
IsSuccessful indicates if the response was successful https://i.sstatic.net/yyI7i.png
Upvotes: 0
Views: 218
Reputation: 168157
I don't think you have JSON.parse()
function in JMeter even if you choose javascript
as the language, switch to groovy
and replace first lines of your assertion code to:
def data = new groovy.json.JsonSlurper().parse(prev.getResponseData())
More information:
if you need more assistance (your "validate that at least one of the 3 tests is true" statement is not clear) - consider updating your question with full response data from the API and indicate your custom pass/fail criteria
Upvotes: 1