Challenge - 5 Problems
Webhook Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What is the output of this webhook registration response?
Consider a webhook registration endpoint that returns a JSON response confirming the registration. What will be the output of the following code snippet when the webhook is successfully registered?
Rest API
response = {
"status": "success",
"message": "Webhook registered successfully",
"webhook_id": 12345
}
print(response)Attempts:
2 left
💡 Hint
Look at how Python prints dictionaries.
✗ Incorrect
The code prints the Python dictionary as is, which uses single quotes for keys and string values.
🧠 Conceptual
intermediate1:00remaining
Which HTTP method is typically used to register a webhook?
When creating a webhook registration endpoint, which HTTP method should be used to send the registration request?
Attempts:
2 left
💡 Hint
Think about sending data to create a new resource.
✗ Incorrect
POST is used to create new resources or submit data to the server, which fits webhook registration.
🔧 Debug
advanced2:00remaining
What error does this webhook registration code raise?
This Python Flask code snippet is intended to register a webhook but raises an error. What error does it raise?
Rest API
from flask import Flask, request, jsonify app = Flask(__name__) @app.route('/register_webhook', methods=['POST']) def register_webhook(): data = request.json url = data['url'] if not url.startswith('http'): return jsonify({'error': 'Invalid URL'}), 400 # Save webhook logic here return jsonify({'status': 'success', 'webhook_url': url}) # Missing app.run() call
Attempts:
2 left
💡 Hint
Check what happens if request.json is None.
✗ Incorrect
If the request body is empty or not JSON, request.json is None, so data['url'] raises TypeError because None is not subscriptable. But here the error is AttributeError because url is None and calling startswith on None fails.
📝 Syntax
advanced1:30remaining
Which option contains the correct JSON schema snippet for webhook registration?
You want to define a JSON schema for validating webhook registration data. Which option is syntactically correct?
Attempts:
2 left
💡 Hint
JSON keys and string values must be in double quotes.
✗ Incorrect
Option D uses correct JSON syntax with double quotes around keys and string values, including the required array.
🚀 Application
expert2:00remaining
What is the number of unique events registered after these webhook registrations?
Assume a webhook registration system where each registration includes a list of events. Given these three registrations, how many unique events are registered in total?
Registration 1: events = ["create", "update"]
Registration 2: events = ["delete", "update"]
Registration 3: events = ["create", "archive"]
Attempts:
2 left
💡 Hint
Count each event only once across all registrations.
✗ Incorrect
The unique events are create, update, delete, archive. That's 4 unique events, but careful: create, update, delete, archive = 4, so answer is 4.