What format will the server expect the request body to be, and what format will it try to respond with?
medium
A. Request body XML, response JSON
B. Request body XML, response XML
C. Request body JSON, response JSON
D. Request body JSON, response XML
Solution
Step 1: Analyze Content-Type header
The Content-Type is application/json, so the server expects JSON data in the request body.
Step 2: Analyze Accept header
The Accept header is application/xml, so the client wants the response in XML format.
Final Answer:
Request body JSON, response XML -> Option D
Quick Check:
Content-Type = JSON, Accept = XML [OK]
Hint: 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
4. 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?
medium
A. Because the HTTP method POST is not allowed
B. Because the Content-Type says JSON but the body is URL-encoded form data
C. Because Accept header is incorrect for JSON
D. Because the Host header is missing
Solution
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.
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.
Final Answer:
Because the Content-Type says JSON but the body is URL-encoded form data -> Option B
Quick Check:
Content-Type must match body format [OK]
Hint: 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
5. You want to send JSON data to an API and receive a JSON response. Which headers should you set correctly in your HTTP request to ensure this communication?
hard
A. Content-Type: application/json and Accept: application/json
B. Content-Type: text/plain and Accept: application/json
C. Content-Type: application/json and Accept: text/html
D. Content-Type: application/xml and Accept: application/json
Solution
Step 1: Set Content-Type for request data
Since you are sending JSON data, set Content-Type: application/json so the server knows the format of the data you send.
Step 2: Set Accept for response format
To receive JSON response, set Accept: application/json to tell the server you want JSON back.
Final Answer:
Content-Type: application/json and Accept: application/json -> Option A
Quick Check:
Both headers set to application/json for JSON exchange [OK]
Hint: Both headers must match JSON for send and receive [OK]
Common Mistakes:
Setting Content-Type and Accept to different formats
Using text/plain or XML when JSON is needed
Forgetting to set Accept header
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.