0
0
Rest APIprogramming~20 mins

Example requests and responses in Rest API - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
REST API Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this GET request example?

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?

A"Alice"
Bnull
Ctrue
D"123"
Attempts:
2 left
💡 Hint

Look at the JSON key name in the response body.

Predict Output
intermediate
2:00remaining
What is the HTTP status code in this response?

Given this HTTP response header:

HTTP/1.1 404 Not Found
Content-Type: application/json
Content-Length: 27

What is the status code number?

A200
B500
C404
D302
Attempts:
2 left
💡 Hint

The status code is the number after HTTP version in the response line.

🧠 Conceptual
advanced
2:00remaining
Which HTTP method is used to update a resource?

In REST APIs, which HTTP method is typically used to update an existing resource?

AGET
BPOST
CDELETE
DPUT
Attempts:
2 left
💡 Hint

Think about which method replaces or modifies a resource.

Predict Output
advanced
2:00remaining
What is the JSON response body from this POST request?

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?

Atrue
Bfalse
C"true"
Dnull
Attempts:
2 left
💡 Hint

Look for the active key in the JSON response.

Predict Output
expert
2:00remaining
What error does this malformed JSON response cause?

Consider this HTTP response body:

{"id":789,"name":"Eve","active":true,}

What error will a JSON parser raise when trying to parse this?

AValueError
BSyntaxError
CKeyError
DTypeError
Attempts:
2 left
💡 Hint

Check the trailing comma after the last key-value pair in JSON.