๐บ LinkedIn:https://www.linkedin.com/in/sidharth-shukla-77b53145/
๐บ Telegram Group: https://t.me/+FTf_NPb--GQ2ODhl
๐ฎIn API testing, it's not sufficient to simply memorize status codes. We also need to have a grasp of testing client-side errors. Let's explore how we can effectively verify various status codes from the 4xx series.
Here are some real-time examples of how you may encounter different HTTP status code:
*********
๐ด 400 Bad Request
*********
Suppose you are working with an e-commerce API, and you attempt to create a new order without providing the required fields, suppose we need to send three fields in request product, customer, quantity but you only send product field.
๐ Request
POST /api/orders
Content Type: application/json
{ "product": "12345" }
๐ Response
400 Bad Request
Content-Type: application/json
{ "error": "Missing required fields: 'customer', 'quantity'" }
******
๐ด 401 Unauthorized
******
When interacting with an authentication API, if you provide incorrect or missing credentials, you may receive a 401 status code:
๐ Request
POST /api/auth/login
Content-Type: application/json {"username": "john", "password": "incorrectpassword" }
๐ Response
401 Unauthorized
Content-Type: application/json
{ "error": "Invalid credentials" }
*****
๐ด 403 Forbidden
*****
Let's say you are accessing an API that requires specific user roles or permissions to perform certain actions.
If you attempt to access a restricted resource without the necessary permissions fo example in below scenario DELETE method can only be done by Admin but you are trying to perform delete action with normal user, you’ll receive a 403 status code.
๐ Request
DELETE /api/users/123
Authorization: Bearer <token>
๐ Response
403 Forbidden
Content-Type: application/json
{ "error": "Insufficient permissions to delete user" }
๐ Try the Complete Interview Q&A Package to crack interviews for Automation Testing and SDET: https://lnkd.in/gJrBGExe
****
๐ด 404 Not Found
****When accessing a resource that doesn't exist, you may receive a 404 status code.
if you query an API for a user that doesn't exist, that means userid 999 not present in DB
๐ Request:
GET /api/users/999
๐ Response:
404 Not Found
Content-Type: application/json
{ "error": "User not found" }
****
๐ด 405 Method Not Allowed
****
Suppose you are interacting with an API that only allows specific HTTP methods for a particular endpoint. If you attempt to use an unsupported method, you will receive a 405 status code,
TIPS: always use OPTIONS method to cross check what all methods are allowed
๐ Request:
PUT /api/customers/123
Content-Type: application/json
{ "name": "John Doe", "email": "john.doe@exa.com" }
๐ Response:
405 Method Not Allowed
Content-Type: application/json
{ "error": "PUT method is not allowed for this endpoint" }
***
E2E API Sessions with Postman, RestAssured, Design Patterns, Architectures, GIT, Jenkins, Framework Design from Scratch: https://lnkd.in/g9r99y8k
***
๐คFor SDET or Automation Testing trainings along with career guidance, mock interviews, design patterns, Generative AI : https://lnkd.in/giCxnJJ7
***
๐ End-to-End Automation & SDET Training:
Boost your testing career with specialized Automation Testing & SDET workshops designed for product companies! Explore API, UI, Mobile, Jenkins, GIT, Docker, and the exciting world of Generative AI. Dive into a unique learning journey featuring personalized 1:1 guidance, interactive mock sessions, and collaborative pair programming, all guided by expert Sidharth Shukla . ๐ Check out the demo now! Demo Session
Enrol Here → https://topmate.io/sidharth_shukla/110008
+++++++
#testing #automation #qa #testautomation #career #softwaretesting #qualityassurance #qaautomation #software #testingtips #assert #testng #sdet #technology #sidpost
SDET Interview Question and Answers
TestNG Interview questions and answers
Jenkins Interview Questions and Answers
Appium Interview Questions and Answers
Selenium Interview Questions and answers