lingareddy_Alva
Esteemed Contributor

Hi @fkseki 

The filter_by parameter is functional, but the error you’re seeing is because you’re passing it as a
Python dict in params — which requests will serialize into query string format — whereas the API
expects a JSON object in the request body for this particular endpoint.

For the list call in the Databricks Budget Policy API, filter_by isn’t a plain query parameter; it’s part
of the request payload (POST), even though it’s a “list” operation

import requests
import json

url = f"https://accounts.azuredatabricks.net/api/2.1/accounts/{account_id}/budget-policies/list"

headers = {
    "Authorization": f"Bearer {TOKEN}",
    "Accept": "application/json",
    "Content-Type": "application/json"
}

payload = {
    "filter_by": {
        "policy_name": "aaaa"
    }
}

response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.status_code, response.text)

Key differences from your attempt:
The method should be POST, not GET.
The filter_by object should be in the request body as JSON, not in params.
The URL is usually <...>/budget-policies/list rather than just /budget-policies.

 

 

 

LR