Databricks Machine Learning Professional Question 114
Single answerYou are configuring a webhook to notify a monitoring system whenever a Databricks machine learning experiment completes. Which code block will correctly trigger the webhook after the experiment run finishes?
- A
response = requests.post(webhook_url, json={'status': 'completed', 'experiment_id': experiment_id})
- B
response = requests.put(webhook_url, data={'status': 'completed', 'experiment_id': experiment_id})
- C
response = requests.get(webhook_url, params={'status': 'completed', 'experiment_id': experiment_id})
- D
response = requests.delete(webhook_url, json={'status': 'completed', 'experiment_id': experiment_id})
Show answer and explanation
Correct answer: A
Explanation
Webhooks are typically triggered using a POST request that sends a payload in JSON format. This ensures the webhook endpoint receives the necessary data in a structured way to process the notification. The correct option follows this pattern.
- A. Correct.
This option correctly uses a POST request with a JSON payload to trigger the webhook, which is the standard method for notifying webhooks.
- B. Incorrect.
This option incorrectly uses a PUT request, which is typically used for updating resources, not for triggering webhooks.
- C. Incorrect.
This option incorrectly uses a GET request, which is used for retrieving data, not for triggering webhooks.
- D. Incorrect.
This option incorrectly uses a DELETE request, which is used for removing resources, not for triggering webhooks.