Select Page

 Introduction of Satatus code 4xx and 500.

API automation test cases gives the HTTP status code 400 more often. In this post I will explain what are the scenarios we get HTTP status code 4xx .

HTTP 400 series status codes are Client Error responses. Meaning the request sent by the Client (Website/Mobile App from any devices) is not valid or cannot be processed, even though the Server(Database/Files/webservers) is reachable. 

Http status code 500 indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

HTTP Status 400 -Bad Request

When Invalid format is passed in JSON in request we get Error code 400.

Common Reasons :

  • Missing required fields

  • Invalid JSON(Missing Commas, Double quotes or Brackets, etc

  • Wrong data type-Sending string instead of Number, Sending Null instead of Required type.


HTTP Status 401 – Unauthorized

401 code means Authentication is required or token is invalid.

Common Reasons :

  • Token is missing – When user forgets or miss to give the token is Authorization we get 401 in the Response

  • Token is expired – When the user is unaware that the token got expired and uses the same token he gets 401 code

  • Wrong credentials-When extra quotation or trim happened by mistake 


HTTP Status 403 – Forbidden

403 code means you are authenticated, but not allowed to access the resource.

For a user who is allowed to use the system/application but when he tries to use a restricted page or functions like Delete then 403 code will be thrown


HTTP Status 404 – Not Found

Meaning the requested resource does not exist.

When the wrong URL or non-existing id is used in the request we get 404 user Not found 

HTTP Status 500 – Internal Server Error

Client sends valid request but the Server crashed or failed while Processing .

Common causes of Error code 500 :

  • Database connection failures

  • Incorrect server configuration

  • Timeout while processing a request

Common causes of Error code 500 :

1.Improper Server configuration.

2.out-of-memory (OOM) issues.

3.Unhandled exceptions.

4.Improper file permissions,

 

Hope you find this post useful and you can guide your API developers to implement them and make it industry standards compliant.