API Testing Questions with Answers

8 practice questions on API Testing (Software Testing & QA) with answers and step-by-step solutions. Try 8 samples below, then practise all 8 free in the AptiNest app.

Sample questions

Question 1Easy

What does HTTP status 404 mean?

  1. The request was successful
  2. The server crashed
  3. The user is not authorised
  4. The requested resource was not found

Answer: D. The requested resource was not found

Explanation

404 Not Found means the server cannot find the resource at the URL.

Step-by-step solution

  1. 4xx is client side.
  2. 404 specifically.
  3. Resource missing.

Why the other options are wrong

  • A. Success is 2xx.
  • B. Server errors are 5xx.
  • C. Authorization is 401 or 403.

Question 2Easy

Which format is most commonly used for REST API request and response bodies today?

  1. JSON
  2. BMP
  3. MP3
  4. ZIP only

Answer: A. JSON

Explanation

JSON is lightweight, readable and widely supported in REST APIs.

Step-by-step solution

  1. REST uses text data.
  2. JSON is common.
  3. Pick JSON.

Why the other options are wrong

  • B. BMP is an image format.
  • C. MP3 is audio.
  • D. ZIP is a container, not a data format for APIs.

Question 3Easy

Which HTTP status code indicates a successful creation of a resource?

  1. 200
  2. 404
  3. 201
  4. 500

Answer: C. 201

Explanation

201 Created is returned after a successful POST that makes a new resource.

Step-by-step solution

  1. POST creates.
  2. Created is 201.
  3. Not 200.

Why the other options are wrong

  • A. 200 means OK for general success.
  • B. 404 means not found.
  • D. 500 means server error.

Question 4Medium

Which HTTP status best fits a request with a valid token but insufficient permission?

  1. 403 Forbidden
  2. 401 Unauthorized
  3. 404 Not Found
  4. 409 Conflict

Answer: A. 403 Forbidden

Explanation

The user is authenticated but not allowed, which is 403. 401 is for missing or invalid credentials.

Step-by-step solution

  1. Token is valid.
  2. Access not allowed.
  3. Forbidden.

Why the other options are wrong

  • B. 401 means missing or invalid authentication.
  • C. 404 hides or misses a resource.
  • D. 409 means a state conflict.

Question 5Medium

What does a contract test between a consumer and a provider API verify?

  1. That the server has enough free memory left on disk
  2. That both sides agree on the message format
  3. That the user interface colours match
  4. That the database is fully encrypted

Answer: B. That both sides agree on the message format

Explanation

Contract tests ensure the provider keeps responses that the consumer relies on.

Step-by-step solution

  1. Agree on format.
  2. Consumer needs fields.
  3. Provider must keep them.

Why the other options are wrong

  • A. That's a capacity matter.
  • C. UI is unrelated.
  • D. Encryption is a security check.

Question 6Medium

In API testing, which part should be validated beyond the status code?

  1. Only the colour in which the response is shown
  2. Only the IP address of the server
  3. Nothing more, because the status code is sufficient
  4. Response body structure, data values and headers

Answer: D. Response body structure, data values and headers

Explanation

A good API test checks status, schema, field values, headers and error messages.

Step-by-step solution

  1. Status alone is insufficient.
  2. Check body.
  3. And headers.

Why the other options are wrong

  • A. Colour is not relevant.
  • B. Not a functional check.
  • C. A 200 with wrong data is still a defect.

Question 7Medium

Which HTTP method is idempotent and typically used to replace a resource?

  1. POST
  2. PATCH always
  3. PUT
  4. CONNECT

Answer: C. PUT

Explanation

PUT sets the resource to the sent representation, so repeating it gives the same state.

Step-by-step solution

  1. Replace uses PUT.
  2. Repeat is same.
  3. Idempotent.

Why the other options are wrong

  • A. POST is not idempotent by default.
  • B. PATCH is not required to be idempotent.
  • D. CONNECT sets up tunnels.

Question 8Hard

An API returns 200 OK with an error message in the body for invalid input. Which is the best assessment?

  1. Correct, 200 is always used for any kind of reply
  2. Correct, all errors should use a 5xx code
  3. Not testable with any API test
  4. A defect; invalid input should give a 4xx code

Answer: D. A defect; invalid input should give a 4xx code

Explanation

Invalid input is a client error, so 400 (or 422) is appropriate rather than a success code.

Step-by-step solution

  1. Invalid input is a client error.
  2. Needs 4xx.
  3. 200 is wrong.

Why the other options are wrong

  • A. Status codes should reflect the outcome.
  • B. 5xx means server faults, not client input.
  • C. It is testable and wrong.

Practise all 8 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Software Testing & QA topics · All topics