Bird
0
0

You have a REST API that returns 200 OK with an empty array when no items match a query. Why might it be better to return 204 No Content instead?

hard📝 Application Q9 of 15
Rest API - HTTP Status Codes
You have a REST API that returns 200 OK with an empty array when no items match a query. Why might it be better to return 204 No Content instead?
A204 is required by REST standards for empty results
B204 forces the client to retry the request
C200 with empty array causes server errors
D204 indicates success with no data, reducing client parsing effort
Step-by-Step Solution
Solution:
  1. Step 1: Understand 204 No Content meaning

    204 means request succeeded but no data is returned.
  2. Step 2: Compare with 200 and empty array

    200 with empty array sends data, 204 saves bandwidth and signals no content clearly.
  3. Final Answer:

    204 indicates success with no data, reducing client parsing effort -> Option D
  4. Quick Check:

    204 means success without data = D [OK]
Quick Trick: Use 204 to signal success with no response body [OK]
Common Mistakes:
  • Thinking 204 causes retries
  • Believing 200 with empty array is error
  • Assuming 204 is mandatory for empty results

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes