Return Status based on the response
Is there a way to return the status code based on the response from the Groovy script of Response tab.
Comments
-
Hi,
Are you looking to model a failure case? For example when it might return a 400 or 500 status code? Usually different responders are used for the different status codes, for example if the first responder doesn't match on correlation then a subsequent responder can be used to return a failure status code.0 -
Example URL: http://localhost:8080/account/{id}
In the response tab using the groovy script I will validate the id and based on some other criteria I need to return the different statuses.My requirement is as below
if(case 1) {
return 200
} else if(case 2) {
return 400
} else {
return XXX
}0 -
Hi,
You could make that validation part of correlation, in which you would have one responder for '200' that would match case 1 and then a second responder for '400' that matches case 2, etc.
0