Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

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.

Tagged:

Comments

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    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.

  • 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
    }

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    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.