- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 02:30 AM
You're absolutely right! Even though I had tried it before, it didn’t work initially. However, I resolved the problem by reviewing the API's structure using the UI. By following the same structure and defining a new alert condition, it worked without any errors. Here's the code I used:
import requests
import json
# Databricks API Details
HOST = "https://<databricks-workspace>.azuredatabricks.net"
TOKEN = "token"
ENDPOINT = f"{HOST}/api/2.0/sql/alerts"
# Function to check the alert API
def check_alert_api():
headers = {
"Authorization": f"Bearer {TOKEN}"
}
response = requests.get(ENDPOINT, headers=headers)
print("Response Data:", json.dumps(response.json(), indent=4))
# Execute the function
check_alert_api()