0
0
Rest APIprogramming~10 mins

API monitoring and alerting 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 send a GET request to check API status.

Rest API
curl -X [1] https://api.example.com/status
Drag options to blanks, or click blank then click option'
AGET
BPOST
CPUT
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of GET to fetch data.
2fill in blank
medium

Complete the code to set a header for JSON content type in the API request.

Rest API
curl -H "Content-Type: [1]" https://api.example.com/data
Drag options to blanks, or click blank then click option'
Aapplication/json
Btext/html
Capplication/xml
Dtext/plain
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text/html' instead of 'application/json' for JSON data.
3fill in blank
hard

Fix the error in the alert condition to trigger when API response time exceeds 500ms.

Rest API
if response_time [1] 500:
    send_alert()
Drag options to blanks, or click blank then click option'
A==
B<
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' causing alerts on fast responses.
4fill in blank
hard

Fill both blanks to create a monitoring script that checks API status code and alerts if not 200.

Rest API
if status_code [1] 200 and status_code [2] 0:
    send_alert()
Drag options to blanks, or click blank then click option'
A!=
B==
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '!=' causing no alerts on errors.
5fill in blank
hard

Fill all three blanks to create a JSON alert payload with API name, status, and response time.

Rest API
{"api": "[1]", "status": [2], "response_time_ms": [3]
Drag options to blanks, or click blank then click option'
AUserService
Bstatus_code
Cresponse_time
DOrderService
Attempts:
3 left
💡 Hint
Common Mistakes
Putting variables in quotes causing them to be treated as strings.