0
0
Testing Fundamentalstesting~10 mins

REST API testing basics in Testing Fundamentals - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to send a GET request using the requests library.

Testing Fundamentals
response = requests.[1]('https://api.example.com/data')
Drag options to blanks, or click blank then click option'
Aget
Bdelete
Cput
Dpost
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of GET when only retrieving data.
Using PUT or DELETE which modify data.
2fill in blank
medium

Complete the code to check if the response status code is 200 (OK).

Testing Fundamentals
assert response.status_code == [1]
Drag options to blanks, or click blank then click option'
A404
B200
C500
D301
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 which means Not Found.
Using 500 which means server error.
3fill in blank
hard

Fix the error in the code to parse JSON response correctly.

Testing Fundamentals
data = response.[1]()
Drag options to blanks, or click blank then click option'
Acontent
Btext
Cjson
Dhtml
Attempts:
3 left
💡 Hint
Common Mistakes
Using text which returns raw string.
Using content which returns bytes.
4fill in blank
hard

Fill both blanks to send a POST request with JSON data.

Testing Fundamentals
response = requests.[1]('https://api.example.com/create', json=[2])
Drag options to blanks, or click blank then click option'
Apost
B{'name': 'John'}
C{'id': 123}
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of POST for sending data.
Passing JSON as a string instead of a dictionary.
5fill in blank
hard

Fill all three blanks to assert the response contains expected data.

Testing Fundamentals
assert [1] in response.json() and response.json()[[2]] == [3]
Drag options to blanks, or click blank then click option'
A'name'
B'status'
C'active'
D'id'
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for wrong keys or values.
Not verifying key existence before value.