Skip to content
CodeKruPro

Use status codes as evidence, not the whole verdict

Automation taskEasyAsked in: Accenture, Capgemini, Infosys, TCS, Wipro

Interviewers ask: "The API returned 200. Is the test passed?" The strong answer is "not yet": you also check the body and the stored data. This lesson practises all three checks.

Use status codes as evidence, not the whole verdict

01 · Read and understand requests

Recommended first: Observe methods instead of assuming they behave alike

Your goal: Use status codes as evidence, not the whole verdict

Follow one request at a time. Send it yourself, then select that response before you answer.

  1. 1Send requests
  2. 2Submit answers

Start here: sign in to practise.

Jump to practice

What you will learn

2xx indicates successful handling, 4xx usually concerns the request or permission and 5xx indicates a server-side failure. These teaching endpoints demonstrate codes; real business correctness still depends on the response and side effects.

Your goals

  • Classify common success and error codes.
  • Recognize a wrong response with a success status.

Before you start

Read the previous lesson first if you have not already. This course does not require programming.

Practice setup

These requests use the public TestKru teaching API. No workspace is needed unless a step says so. Leave the body empty for GET, HEAD and OPTIONS. Example people and emails are fictional. Changes to /api/users are simulated and are not saved.

Supplied training evidence / contract

Supplied business fixture: contract says an order total must be non-negative; HTTP 200 body is {"total":-10,"currency":"USD"}. The HTTP exchange succeeded, but this body violates the supplied business rule.

Follow these steps

  1. Send each status example once and select its response. Send the 500 example only once. That status is intentional.
  2. For 204, look at the body. This 201 example only shows a status code. A real create would also return an id. This GET does not create a record.
  3. Read the supplied order fixture. The status is 200. Decide whether the total follows the rule that a total must not be negative.
  4. Classify the 400 example and the 500 example.
  5. Submit Answers. In self-review, look up what 401, 403, 404, 409 and 429 usually mean. You do not need to send those yet.

Investigate before concluding

First record the actual result for each case. Compare the body, headers and later state with the stated contract. Keep an observation separate from a prediction; use the model answer only after making your own attempt.

What to keep as evidence

  • The 204 body is not treated as an error.
  • 4xx and 5xx are distinguished.
  • Business fields are checked even when HTTP succeeds.
References for this lesson

Finish this assignment

Select each named response with Use this response. Answer from those responses or the transcript on this page. Click Submit Answers. Your score is the percentage of checks that passed. Core checks are required to finish. Extra evidence checks are labelled. A saved 100/100 means every check passed. Continue opens the next lesson you can submit.

If something goes wrong
  • Change one part of the request at a time. If a check needs attention, read the note under it and compare it with the response you selected.
Self-review and independent variation
  • The 204 body is not treated as an error.
  • 4xx and 5xx are distinguished.
  • Business fields are checked even when HTTP succeeds.

For 429 inspect Retry-After and wait; do not flood an endpoint to force a code.

Automatic checks verify the requests and answers configured for this lesson. The self-review is for your own reasoning. A score is not a certificate.

Open API reference

Practise and save your evidence

The lesson is public. Sign in to send requests and save progress. You will return to this lesson.

Sign in to practiseCreate an account