Returning only 500 Internal Service Error instead of 200 with response

mentzzzmentzzz Posts: 6

Is there a way to set up my mock to only return a 500 error if we enter in a unique value correlated to this? For example right now we have our mock set up to look for "JORDANS_CATEGORY" and this would return a valid response (200) that is set up in our traffic file. Is there a way to return only a HTTP status code instead of just a custom error message?

Comments

  • williammccuskerwilliammccusker Posts: 433 ✭✭

    Hi,

    I want to make sure I understand your case. You have a responder that was created from traffic and it is returning when the values matches. In that case you are getting back a 200 response code. For values that do not match the correlation you would like to return a different status code that 500?

    It sounds like the "500" you might be seeing is the default response when no matching responder can be found. You can add a "catch all" responder as the last responder in your virtual asset and then customize what the response status code is from the "Options" tab on the response in the section named "Return Status"

  • mentzzzmentzzz Posts: 6

    Thanks for the super fast response. For values that do not match the correlation we really don't care what status code is returned, but if we entered in "INTERNAL_ERROR" instead of "JORDANS_CATEGORY" as our unique value then we would want that to return 500 no matter what. Can that be done the way you were saying?

  • williammccuskerwilliammccusker Posts: 433 ✭✭

    Hi,

    Yes I believe what you are asking can be done that way. The status code and message are configurable from "Options" in "Return status." Placing a "catch all" responder as the last responder in your virtual asset without and correlation conditions will make so that anything that didn't match to the first responder will instead get the response code and message configured on the "catch all" responder.

  • mentzzzmentzzz Posts: 6

    How can I make a catch all responder? All of my responses are custom responses that are coming from a custom traffic file.

  • mentzzzmentzzz Posts: 6

    I believe I have figured it out, I just created a literal message responder and made it to where there are no responder correlations and set the return status to match what i need. Does this sound correct? Thanks for all of the help so far!

  • mentzzzmentzzz Posts: 6

    Also, is there a way to return 400 for a certain request before it returns the 500 one?

  • williammccuskerwilliammccusker Posts: 433 ✭✭

    Hi,
    Yes using a literal responder with no correlation sounds correct.

    For the of returning 400 do you have a correlation for that case? Then you could setup another literal responder with the correlation conditions set and put it before the responder that returns 500. Responders are checked in order for a match and the first one to match returns the response so as long as the 400 responder matches and comes before the responder with 500 then it will work.

  • mentzzzmentzzz Posts: 6

    Perfect, I think i have it figured out thanks to you. You are awesome, thanks William!

  • williammccuskerwilliammccusker Posts: 433 ✭✭

    Glad I could help!

  • Saurabh1509Saurabh1509 Posts: 3

    Can we use data source correlation for catch all message Responder ??

  • williammccuskerwilliammccusker Posts: 433 ✭✭

    Hi,
    The term "catch all" for responders usually means a responder configured without any correlations so that it will match to all messages. You certainly can configure a responder with data source correlation but that it will only match specific messages determined by the data source correlation.

Sign In or Register to comment.