Complete the code to send a GET request to the API endpoint.
response = requests.[1]('https://api.example.com/data')
The GET method is used to retrieve data from the API, which is essential for validating backend logic.
Complete the code to check if the API response status code is 200 (OK).
assert response.[1] == 200
The status_code attribute holds the HTTP status code returned by the API, which indicates success or failure.
Fix the error in the assertion that checks if the 'success' field in JSON response is True.
assert response.json()[[1]] == True
The key must be a string matching exactly the JSON field name, so it needs quotes around 'success'.
Fill both blanks to extract the 'user_id' from JSON response and check if it equals 123.
user_id = response.json().[1]('user_id') assert user_id [2] 123
Use get to safely access 'user_id' and == to compare values.
Fill all three blanks to send a POST request with JSON data and check if response status is 201.
payload = {'name': 'Alice', 'age': 30}
response = requests.[1]('https://api.example.com/users', json=[2])
assert response.[3] == 201Use post to send data, pass payload as JSON, and check status_code for 201 Created.