0
0
Testing Fundamentalstesting~20 mins

REST API testing basics in Testing Fundamentals - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
REST API Testing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the HTTP status code returned by this GET request?

Consider a REST API endpoint /users/123 that returns user details if the user exists. The user with ID 123 exists.

What HTTP status code should the server return for a successful GET request to /users/123?

A404 Not Found
B200 OK
C500 Internal Server Error
D201 Created
Attempts:
2 left
💡 Hint

Think about the standard response for a successful data retrieval.

assertion
intermediate
1:30remaining
Which assertion correctly verifies the JSON response contains the expected user name?

You receive this JSON response from a REST API:

{"id": 123, "name": "Alice", "email": "alice@example.com"}

Which assertion correctly checks that the name field is Alice?

Aassert response.json()['name'] == 'Alice'
Bassert response['name'] == 'Alice'
Cassert response.json()['name'] = 'Alice'
Dassert response.get('name') == 'Alice'
Attempts:
2 left
💡 Hint

Remember how to access JSON data from a response object.

locator
advanced
1:30remaining
Which HTTP header is best to locate the API version in a request?

You want to test a REST API that supports multiple versions. Which HTTP header is the best practice to specify the API version in your request?

AAuthorization
BContent-Type
CUser-Agent
DAccept
Attempts:
2 left
💡 Hint

Think about which header tells the server what format or version the client expects.

🔧 Debug
advanced
2:00remaining
Why does this POST request test fail with a 400 Bad Request?

Test code sends this JSON payload in a POST request:

{"username": "bob", "password": 12345}

The API expects the password as a string, but the test fails with 400 Bad Request. Why?

APassword is sent as a number, but API expects a string
BUsername field is missing
CPOST method is not allowed on this endpoint
DJSON payload is missing required headers
Attempts:
2 left
💡 Hint

Check the data types in the JSON payload.

framework
expert
2:30remaining
Which test framework feature best supports automated REST API testing with setup and teardown?

You want to write automated tests for REST APIs that require preparing test data before tests and cleaning up after. Which feature of a test framework best supports this?

AParameterized tests
BMocking HTTP requests
CFixtures or setup/teardown methods
DSnapshot testing
Attempts:
2 left
💡 Hint

Think about how to prepare and clean test environments automatically.