- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2025 07:25 AM
Hi everyone,
I'm trying to use the filter_by parameter in a GET request to /api/2.0/sql/history/queries, but I keep getting a 400 Bad Request error. When I use max_results, it works fine, but adding filter_by causes the request to fail.
Example value for filter_by in the request:
{
"statuses":["FINISHED","CANCELED"],
"query_start_time_range":{
"start_time_ms" : 1640995200000,
"end_time_ms" : 1641081599000
}
}
Response
{
"error_code": "MALFORMED_REQUEST",
"message": "Could not parse request object: Expected 'START_OBJECT' not 'VALUE_STRING'\n at [Source: (ByteArrayInputStream); line: 1, column: 15]\n at [Source: java.io.ByteArrayInputStream@28488ac8; line: 1, column: 15]"
}
I've tried several variations, but I keep getting the same error. Unfortunately, the documentation does not include an example of how to format filter_by correctly in the query string.
Has anyone successfully used filter_by in this API? If so, could you share a working example?
Thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2025 01:57 PM
Here's how you can do it.
import requests
import json
api_endpoint = "https://test-1.cloud.databricks.com/api/2.0/sql/history/queries"
headers = {
"Authorization": "Bearer XXXXXX”
}
params = json.dumps({
"filter_by": {
"user_id": "5342291138747455", # Example filter: queries executed by a specific user
"query_start_time_range": {
"start_time_ms": 1640995200000, # Example start time in milliseconds
"end_time_ms": 1641081599000 # Example end time in milliseconds
}
}
})
response = requests.get(api_endpoint, headers=headers, params=params)
# Parse the response
data = response.json()
print(json.dumps(data, indent=4))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2025 01:57 PM
Here's how you can do it.
import requests
import json
api_endpoint = "https://test-1.cloud.databricks.com/api/2.0/sql/history/queries"
headers = {
"Authorization": "Bearer XXXXXX”
}
params = json.dumps({
"filter_by": {
"user_id": "5342291138747455", # Example filter: queries executed by a specific user
"query_start_time_range": {
"start_time_ms": 1640995200000, # Example start time in milliseconds
"end_time_ms": 1641081599000 # Example end time in milliseconds
}
}
})
response = requests.get(api_endpoint, headers=headers, params=params)
# Parse the response
data = response.json()
print(json.dumps(data, indent=4))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 06:32 AM
Hi Alberto,
I just wanted to thank you for your suggestion. Thanks to your input, I was able to successfully use the API with filters. I really appreciate your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 06:37 AM
Hi @lukamu, glad that it worked for you!

