Bird
0
0

Given this HTTP request snippet:

medium📝 Predict Output Q13 of 15
Rest API - Request and Response Format
Given this HTTP request snippet:
POST /api/data HTTP/1.1
Host: example.com
Content-Type: application/json
Accept: application/xml

{"name": "Alice"}

What format will the server expect the request body to be, and what format will it try to respond with?
ARequest body XML, response JSON
BRequest body XML, response XML
CRequest body JSON, response JSON
DRequest body JSON, response XML
Step-by-Step Solution
Solution:
  1. Step 1: Analyze Content-Type header

    The Content-Type is application/json, so the server expects JSON data in the request body.
  2. Step 2: Analyze Accept header

    The Accept header is application/xml, so the client wants the response in XML format.
  3. Final Answer:

    Request body JSON, response XML -> Option D
  4. Quick Check:

    Content-Type = JSON, Accept = XML [OK]
Quick Trick: Content-Type = sent data, Accept = wanted response [OK]
Common Mistakes:
  • Mixing up Content-Type and Accept roles
  • Assuming response matches request format
  • Ignoring headers and guessing defaults

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes