Bird
0
0

You want to send a nested JSON object in the request body to create a user with address info:

hard📝 Application Q15 of 15
Rest API - Request and Response Format
You want to send a nested JSON object in the request body to create a user with address info:
{
  "name": "Eve",
  "address": {
    "street": "123 Main St",
    "city": "Townsville"
  }
}

Which Content-Type header and body format should you use to ensure the server correctly understands this nested data?
AContent-Type: application/json with the JSON body as shown
BContent-Type: text/plain with JSON body as string
CContent-Type: application/x-www-form-urlencoded with nested keys
DContent-Type: multipart/form-data with JSON inside a file
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct header for nested JSON

    Nested JSON requires application/json Content-Type so the server parses the structure correctly.
  2. Step 2: Evaluate other formats

    text/plain treats body as plain text, application/x-www-form-urlencoded does not support nested objects well, and multipart/form-data is for files, not nested JSON.
  3. Final Answer:

    Content-Type: application/json with the JSON body as shown -> Option A
  4. Quick Check:

    Nested JSON needs application/json header [OK]
Quick Trick: Use application/json header for nested JSON objects [OK]
Common Mistakes:
MISTAKES
  • Using form-urlencoded for nested JSON
  • Sending JSON as plain text without header
  • Uploading JSON as file instead of body

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes