0
0
Rest APIprogramming~20 mins

Client-server architecture in Rest API - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Client-Server 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 simple REST API client request?

Consider this Python code using requests to get data from a server:

import requests
response = requests.get('https://jsonplaceholder.typicode.com/posts/1')
print(response.status_code)

What will this print?

Rest API
import requests
response = requests.get('https://jsonplaceholder.typicode.com/posts/1')
print(response.status_code)
A403
B500
C200
D404
Attempts:
2 left
💡 Hint

Think about what status code means a successful GET request.

🧠 Conceptual
intermediate
1:30remaining
Which component is responsible for processing client requests in client-server architecture?

In a client-server model, which part handles the incoming requests and sends back responses?

ADatabase
BClient
CRouter
DServer
Attempts:
2 left
💡 Hint

Think about who listens and responds to requests.

🔧 Debug
advanced
2:00remaining
What error will this REST API client code raise?

Look at this Python code snippet:

import requests
response = requests.get('https://jsonplaceholder.typicode.com/posts/abc')
print(response.json()['id'])

What error will occur when running this code?

AKeyError
BJSONDecodeError
CTypeError
DNo error, prints 'abc'
Attempts:
2 left
💡 Hint

Check what the server returns for an invalid post id and what keys exist in the JSON.

📝 Syntax
advanced
2:00remaining
Which option correctly sends JSON data in a POST request?

Which Python code snippet correctly sends JSON data to a REST API server?

Arequests.post(url, data={'name': 'Alice'})
Brequests.post(url, json={'name': 'Alice'})
Crequests.post(url, body={'name': 'Alice'})
Drequests.post(url, payload={'name': 'Alice'})
Attempts:
2 left
💡 Hint

Remember the parameter that automatically encodes JSON in requests.

🚀 Application
expert
2:30remaining
How many items will this server return in the JSON list?

A REST API server returns this JSON response for GET /users?active=true:

[{"id":1,"active":true},{"id":2,"active":true},{"id":3,"active":false},{"id":4,"active":true}]

How many user objects will the client receive if the server filters correctly?

A3
B4
C2
D1
Attempts:
2 left
💡 Hint

Count only users with active set to true.