Making JMeter Accept HTTP 404 (or any 4xx) as Success

One of the projects I am currently working on involves re-writing a REST service from one framework to another. I'm in the testing phase, and am trying to make sure the new endpoints behave the same as the old version.

One of the tests I am performing is to replay a month's worth of GET requests from production against this service, and look for differences in the output. I also want to highlight any that have an unknown status code. It is possible for this service to return a 200/OK or 404/NOT_FOUND, anything else indicates an error. In this case, I am ok, and actually expect 404's in the results.

Due to the one-off bulk nature of this test, I'm using JMeter to run this test. JMeter reports any response code of 400 or higher as an error, so I needed to find a way to change that. There are a few options, but the simplest I could find was the following:

  1. Create a Response Assertion, either at the same level or as a child of the HTTP request
  2. Field to Test: Response Code
  3. Check Ignore Status
  4. Pattern Matching RulesMatches
  5. Add a regular expression of the status codes you want to test against. In this case, 200|404

1 thought on “Making JMeter Accept HTTP 404 (or any 4xx) as Success”

Leave a Reply