I'm trying to get my billing usage data from Databricks API (documentation: https://docs.databricks.com/api/gcp/account/billableusage/download) but I keep getting an 404 error.
Code:
import requests
import json
token = dbutils.notebook.entry_point.getDbutils().notebook().getContext().apiToken().get()
api_url = f"{my_domain_url}/api/2.0/accounts/{my_account_id}/usage/download"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
params = {
"start_month": "2023-06",
"end_month": "2023-07"
}
response = requests.get(api_url, headers=headers, params=params)
if response.status_code == 200:
cost_data_csv = response.content.decode('utf-8')
print("Usage logs downloaded successfully.")
else:
print("Error:", response.status_code, response.text)
Error: 404 {"error":"Bad Target: /api/2.0/accounts/<my_account_id>/usage/download"}
Note: I've already attempted modifying the URL prefix from /api/2.0 to /api/2.1 and have also thoroughly verified the accuracy of both my account ID and domain URL.