0
0
Rest APIprogramming~10 mins

Load testing in Rest API - Interactive Code Practice

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

Complete the code to set the number of virtual users in the load test.

Rest API
virtual_users = [1]
Drag options to blanks, or click blank then click option'
A100
Busers
Crequests
Dduration
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names instead of a number.
Setting duration instead of user count.
2fill in blank
medium

Complete the code to specify the HTTP method for the load test request.

Rest API
method = '[1]'
Drag options to blanks, or click blank then click option'
AGET
BFETCH
CSEND
DPOSTS
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-standard HTTP verbs.
Adding extra characters to the method name.
3fill in blank
hard

Fix the error in the code to correctly set the test duration in seconds.

Rest API
duration = [1]
Drag options to blanks, or click blank then click option'
Asixty
B'60s'
C60
D60sec
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings instead of numbers for duration.
Adding units inside the value.
4fill in blank
hard

Fill both blanks to create a dictionary that sets headers and the URL for the load test.

Rest API
config = {'headers': [1], 'url': '[2]'}
Drag options to blanks, or click blank then click option'
A{'Content-Type': 'application/json'}
B{'Accept': 'text/html'}
Chttps://api.example.com/data
Dhttp://localhost
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect header keys.
Using invalid URLs.
5fill in blank
hard

Fill all three blanks to create a load test function that sends a POST request with JSON data.

Rest API
def load_test():
    response = requests.[1](
        url='[2]',
        json=[3]
    )
    return response.status_code
Drag options to blanks, or click blank then click option'
Apost
Bhttps://api.example.com/submit
C{'key': 'value'}
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' instead of 'post' for sending data.
Passing data as a string instead of a dictionary.