#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
API Testing

API Testing Components

Key Components of an API Request/Response

  • Endpoint (URL): the address the request is sent to.
  • HTTP Method: GET, POST, PUT, DELETE, PATCH — indicating the action to perform.
  • Headers: metadata such as content type or authorization tokens.
  • Request Body/Payload: the data sent with the request (commonly JSON).
  • Status Code: a numeric response indicating success or failure (e.g., 200, 404, 500).
  • Response Body: the data returned by the server.

Why Understanding These Matters

A tester needs to know exactly which of these components to construct for the request and which to validate in the response to write an effective API test.

Anatomy of a Real Request and Response

Here is a complete example showing every component together. The client creates an order:

POST /api/v1/orders?notify=true HTTP/1.1
Host: shop.example.com
Content-Type: application/json
Authorization: Bearer <token>

{
  "productId": 4521,
  "quantity": 2
}

The server replies:

HTTP/1.1 201 Created
Content-Type: application/json
Location: /api/v1/orders/9876

{
  "orderId": 9876,
  "status": "PLACED",
  "total": 1598.00
}

Notice two pieces not listed earlier: query parameters (notify=true) that modify the request through the URL, and path parameters such as the order ID inside /orders/9876. Response headers like Location also carry useful information worth testing.

A good habit is to follow the Location header with a GET request. If the new order comes back with the same product and quantity you sent, you have confirmed that the data was really saved, not just acknowledged.

What to Check in Each Component

ComponentWhat a Tester Verifies
Endpoint and parametersCorrect path, required parameters enforced, invalid IDs handled
MethodUnsupported methods return 405; GET does not change data
HeadersMissing or wrong Content-Type rejected; Authorization required where expected
BodyRequired fields, data types, length limits, extra or missing fields
Status codeMatches the outcome: 201 for create, 400 for bad input, 401 or 403 for auth problems, 404 for missing resources
Response bodyField values, data types, structure against the agreed schema, helpful error messages
Response timeStays within the agreed limit for typical requests

Status Code Families at a Glance

  • 2xx success: 200 OK, 201 Created, 204 No Content.
  • 3xx redirection: the resource lives elsewhere.
  • 4xx client errors: 400 Bad Request, 401 Unauthorized (not logged in), 403 Forbidden (logged in but not allowed), 404 Not Found, 409 Conflict, 422 validation failure in many APIs.
  • 5xx server errors: 500 Internal Server Error, 503 Service Unavailable. A 5xx caused by bad input is itself a defect, because the server should have returned a 4xx.

Common Gaps in API Test Coverage

  • Checking only that the status is 200 without reading the body.
  • Never sending a request without a token, or with another user's token, to confirm access control.
  • Ignoring headers, such as the response Content-Type or caching headers.
  • Skipping schema validation, so a renamed field slips through unnoticed.
  • Testing only valid input. Empty strings, very long values, wrong types and negative numbers often reveal bugs.

Practical habit: for every endpoint, write at least one positive test, one validation test and one authorization test before adding more detailed cases.

Ready to master real-world software testing?

Learn manual and automation testing hands-on with mentor-led sessions.

Explore Course