Recall & Review
beginner
What is the purpose of the request body in a REST API?
The request body carries the data sent from the client to the server, usually when creating or updating resources.
Click to reveal answer
beginner
Name two common formats used for the request body in REST APIs.
JSON (JavaScript Object Notation) and XML (eXtensible Markup Language) are common formats for request bodies.
Click to reveal answer
beginner
Why is it important to set the 'Content-Type' header when sending a request body?
The 'Content-Type' header tells the server the format of the data in the request body, so it can parse it correctly.
Click to reveal answer
intermediate
What happens if you send a request body with a GET request?
Typically, GET requests do not have a request body. Sending one may be ignored or cause unexpected behavior.
Click to reveal answer
beginner
How do you structure a JSON request body to create a new user with name and email?
You create a JSON object with keys and values, for example: {"name": "Alice", "email": "alice@example.com"}.
Click to reveal answer
What header must you include to tell the server the format of the request body?
✗ Incorrect
The Content-Type header specifies the media type of the request body.
Which HTTP method usually includes a request body?
✗ Incorrect
POST requests commonly include a request body to send data to the server.
What is the most common format for request bodies in REST APIs?
✗ Incorrect
JSON is widely used because it is easy to read and write for humans and machines.
If you forget to set the Content-Type header, what might happen?
✗ Incorrect
Without Content-Type, the server may not understand how to read the request body.
Which of these is a valid JSON request body to update a user's age to 30?
✗ Incorrect
Valid JSON requires keys in double quotes and proper syntax.
Explain what a request body is and why it is used in REST APIs.
Think about when you fill a form and send it to a website.
You got /3 concepts.
Describe how to properly format a JSON request body and what headers to include.
Remember the curly braces and quotes in JSON.
You got /3 concepts.