Bird
0
0

You wrote this HTTP request:

medium📝 Debug Q14 of 15
Rest API - Request and Response Format
You wrote this HTTP request:
POST /submit HTTP/1.1
Host: example.com
Content-Type: application/json
Accept: application/json

name=John&age=30

Why might the server reject this request or fail to parse the data?
ABecause the HTTP method POST is not allowed
BBecause the Content-Type says JSON but the body is URL-encoded form data
CBecause Accept header is incorrect for JSON
DBecause the Host header is missing
Step-by-Step Solution
Solution:
  1. Step 1: Check Content-Type and body format

    The Content-Type is application/json, but the body is name=John&age=30, which is URL-encoded form data, not JSON.
  2. Step 2: Understand server parsing behavior

    The server expects JSON data but receives form data, so it may reject or fail to parse the request.
  3. Final Answer:

    Because the Content-Type says JSON but the body is URL-encoded form data -> Option B
  4. Quick Check:

    Content-Type must match body format [OK]
Quick Trick: Match Content-Type with actual body format [OK]
Common Mistakes:
  • Ignoring mismatch between Content-Type and body
  • Assuming Accept header affects request body
  • Thinking Host header is missing when it is present

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes