Challenge - 5 Problems
Request Body Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this JSON request body?
Given this JSON request body sent to an API, what is the value of the "totalPrice" field after the server calculates it?
Rest API
{
"items": [
{"name": "apple", "quantity": 2, "price": 3},
{"name": "banana", "quantity": 1, "price": 1}
],
"totalPrice": 0
}Attempts:
2 left
💡 Hint
Multiply quantity by price for each item and add them up.
✗ Incorrect
The total price is (2 * 3) + (1 * 1) = 6 + 1 = 7.
🧠 Conceptual
intermediate1:00remaining
Which HTTP method usually requires a request body?
Choose the HTTP method that typically sends data in the request body to create or update resources.
Attempts:
2 left
💡 Hint
Think about sending new data to the server.
✗ Incorrect
POST requests usually include a request body to send data to the server.
🔧 Debug
advanced2:00remaining
What error will this JSON request body cause?
This JSON request body is sent to an API expecting a list of users. What error will the server likely return?
Rest API
{
"users": {
"name": "Alice",
"age": 30
}
}Attempts:
2 left
💡 Hint
The server expects a list but got a single object.
✗ Incorrect
The server expects 'users' to be a list, but the JSON has an object instead, causing a TypeError.
📝 Syntax
advanced1:30remaining
Which JSON request body is syntactically correct?
Select the JSON request body that is valid and can be parsed without errors.
Attempts:
2 left
💡 Hint
Look for trailing commas and missing quotes.
✗ Incorrect
Option B is valid JSON. Option B has a trailing comma, C is missing a closing brace, D uses unquoted keys.
🚀 Application
expert1:00remaining
How many items are in the 'products' list in this JSON request body?
Count the number of product objects inside the 'products' array in this JSON request body.
Rest API
{
"products": [
{"id": 1, "name": "Pen"},
{"id": 2, "name": "Notebook"},
{"id": 3, "name": "Eraser"},
{"id": 4, "name": "Ruler"}
]
}Attempts:
2 left
💡 Hint
Count each object inside the square brackets.
✗ Incorrect
There are 4 product objects inside the 'products' array.