200-901 Question 47
Select 3A developer is troubleshooting an HTTP response from their API and observes the following:
HTTP/1.1 404 Not Found Content-Type: application/json Content-Length: 85
{"error": "Resource not found", "code": 404, "details": "The requested item was not found."}
Which parts of the HTTP response are correctly identified?
- A
The response code is 404, indicating a client error.
- B
The Content-Type header specifies the type of data in the body as JSON.
- C
The body contains the metadata about the HTTP protocol used.
- D
The Content-Length header specifies the size of the response body in bytes.
- E
The response code is part of the HTTP headers.
Show answer and explanation
Correct answers: A, B, D
Explanation
An HTTP response consists of three main parts: the status line (which includes the response code like 404), the headers (such as Content-Type and Content-Length), and the body (which contains the actual response data). Understanding these components helps developers interpret and troubleshoot API responses effectively.
- A. Correct.
Correct: The response code 404 indicates a client error where the requested resource could not be found.
- B. Correct.
Correct: The 'Content-Type' header specifies the format of the response body, which is JSON in this case.
- C. Incorrect.
Incorrect: The body contains the actual data returned by the server, not metadata about the HTTP protocol.
- D. Correct.
Correct: The 'Content-Length' header specifies the size of the response body, which is 85 bytes in this example.
- E. Incorrect.
Incorrect: The response code is part of the HTTP status line, not the headers.