0
0
Rest APIprogramming~20 mins

Webhook registration endpoint in Rest API - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Webhook Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1: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)
A{"status": "success", "message": "Webhook registered successfully", "webhook_id": 12345}
B{'status': 'success', 'message': 'Webhook registered successfully', 'webhook_id': 12345}
CWebhook registered successfully with ID 12345
DError: webhook_id missing
Attempts:
2 left
💡 Hint
Look at how Python prints dictionaries.
🧠 Conceptual
intermediate
1: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?
APOST
BGET
CDELETE
DPUT
Attempts:
2 left
💡 Hint
Think about sending data to create a new resource.
🔧 Debug
advanced
2: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
ATypeError: 'str' object is not callable
BRuntimeError: Working outside of request context
CAttributeError: 'NoneType' object has no attribute 'startswith'
DNo error, runs successfully
Attempts:
2 left
💡 Hint
Check what happens if request.json is None.
📝 Syntax
advanced
1: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?
A
{
  "type": "object",
  "properties": {
    "url": {"type": "string", "format": "uri"},
    "events": {"type": "array", "items": {"type": "string"}}
  },
  "required": [url, events]
}
B
{
  type: "object",
  properties: {
    url: {type: "string", format: "uri"},
    events: {type: "array", items: {type: "string"}}
  },
  required: ["url", "events"]
}
C
{
  "type": "object",
  "properties": {
    "url": {"type": "string", "format": "uri"},
    "events": {"type": "array", "items": {"type": "string"}}
  },
  required: ["url", "events"]
}
D
{
  "type": "object",
  "properties": {
    "url": {"type": "string", "format": "uri"},
    "events": {"type": "array", "items": {"type": "string"}}
  },
  "required": ["url", "events"]
}
Attempts:
2 left
💡 Hint
JSON keys and string values must be in double quotes.
🚀 Application
expert
2: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"]
A4
B5
C3
D6
Attempts:
2 left
💡 Hint
Count each event only once across all registrations.