</>

Technology

Rest Assured

Difficulty

Beginner

Interview Question

What are the types of HTTP status codes in API testing?

Answer

HTTP Status Code Categories

RangeCategoryMeaning
1xxInformationalRequest was received, continuing process
2xxSuccessfulRequest was successfully received, understood, and accepted
3xxRedirectionFurther action needs to be taken to complete the request
4xxClient ErrorRequest contains bad syntax or cannot be fulfilled
5xxServer ErrorServer failed to fulfil an apparently valid request

Most Common Status Codes in API Projects

CodeNameWhen You See It
200OKSuccessful GET or PUT request
201CreatedSuccessful POST — resource created
204No ContentSuccessful DELETE — nothing to return
302RedirectResource temporarily moved
400Bad RequestMissing/invalid request parameters
401UnauthorizedMissing or invalid authentication token
403ForbiddenAuthenticated but lacks permission
404Not FoundResource does not exist
405Method Not AllowedHTTP method not supported for that endpoint
417Expectation FailedServer cannot meet the Expect header requirement
422Unprocessable EntityValidation failed on request body
500Internal Server ErrorServer crashed or encountered an unexpected error

Tips for Testers

  • Always verify the correct status code, not just 200
  • Test both happy path (2xx) and error paths (4xx, 5xx)
  • Use assertEquals(response.getStatusCode(), 200) in Rest Assured

Follow AutomateQA

Related Topics