Consider this HTTP GET request to fetch user data:
GET /users/123 HTTP/1.1 Host: api.example.com Accept: application/json
The server responds with this JSON body:
{"id":123,"name":"Alice","active":true}What is the value of the name field in the response?
Look at the JSON key name in the response body.
The response JSON has a key name with value "Alice". So the correct answer is "Alice".
Given this HTTP response header:
HTTP/1.1 404 Not Found Content-Type: application/json Content-Length: 27
What is the status code number?
The status code is the number after HTTP version in the response line.
The response line is HTTP/1.1 404 Not Found, so the status code is 404.
In REST APIs, which HTTP method is typically used to update an existing resource?
Think about which method replaces or modifies a resource.
The PUT method is used to update or replace an existing resource in REST APIs.
A client sends this POST request to create a new user:
POST /users HTTP/1.1
Host: api.example.com
Content-Type: application/json
{"name":"Bob","age":30}The server responds with:
{"id":456,"name":"Bob","age":30,"active":true}What is the value of the active field in the response?
Look for the active key in the JSON response.
The active field is a boolean true in the JSON response.
Consider this HTTP response body:
{"id":789,"name":"Eve","active":true,}What error will a JSON parser raise when trying to parse this?
Check the trailing comma after the last key-value pair in JSON.
JSON does not allow a trailing comma after the last item, so the parser raises a SyntaxError.