Bird
0
0

Which of the following is the correct way to send a 404 Not Found response in a REST API using HTTP headers?

easy📝 Syntax Q12 of 15
Rest API - HTTP Status Codes
Which of the following is the correct way to send a 404 Not Found response in a REST API using HTTP headers?
AHTTP/1.1 403 Forbidden\r\nContent-Type: application/json\r\n\r\n
BHTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n
CHTTP/1.1 404 Not Found\r\nContent-Type: application/json\r\n\r\n
DHTTP/1.1 500 Internal Server Error\r\nContent-Type: text/html\r\n\r\n
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct HTTP status line for 404

    The status line must start with HTTP version and '404 Not Found' to indicate missing resource.
  2. Step 2: Check headers format

    Headers like Content-Type follow the status line, separated by CRLF, then a blank line before body.
  3. Final Answer:

    HTTP/1.1 404 Not Found\r\nContent-Type: application/json\r\n\r\n -> Option C
  4. Quick Check:

    Status line with 404 and proper headers = HTTP/1.1 404 Not Found\r\nContent-Type: application/json\r\n\r\n [OK]
Quick Trick: 404 response starts with 'HTTP/1.1 404 Not Found' [OK]
Common Mistakes:
MISTAKES
  • Using 200 OK status for missing resource
  • Mixing 404 with 500 or 403 status codes
  • Incorrect header formatting or missing blank line

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes