200-901 · Question #506
200-901 Question #506: Real Exam Question with Answer & Explanation
The correct answer is A: Accept: application/xml; q=0.5, application/json. The HTTP Accept header is used by a client to declare which response content types it will accept, ensuring the server returns data in the preferred format.
Question
The API documentation has this requirement for a REST API request: "For methods that accept request parameters, the platform accepts either application/json or application/x-www-form-urlencoded content types and currently only supports returning data in application/json format." Which field returns content in the required format? A. B. C. D.
Options
- AAccept: application/xml; q=0.5, application/json
- BContent-Type: application/json
- CContent-Type : application/xml; q=0.5, application/json
- DExpect: application/json
Explanation
The HTTP Accept header is used by a client to declare which response content types it will accept, ensuring the server returns data in the preferred format.
Common mistakes.
- B. Content-Type describes the format of the data the client is sending in the request body; it has no effect on the format of the server's response.
- C. Content-Type with an XML preference still controls only the outgoing request body format, and specifying XML would conflict with the server's JSON-only response capability.
- D. The Expect header is used for handshake behaviors such as 100-continue and is not a content negotiation mechanism for specifying response media types.
Concept tested. HTTP Accept header content negotiation
Reference. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
Topics
Community Discussion
No community discussion yet for this question.