Pooyan
03/20/2025, 7:04 PMurl = f"{prefect_api_url}/flow_runs/filter"
headers = {
"Content-Type": "application/json"
}
payload = {
"flow_run_filter": {
"flow_id": {
"any_": ["xxyy"]
}
},
"sort": "START_TIME_DESC",
"limit": 20,
"offset": 0,
}
response = <http://requests.post|requests.post>(url, json=payload, headers=headers)
Marvin
03/20/2025, 7:05 PMflow_id
is slightly off. In Prefect, the filtering mechanism for flow runs should be structured correctly to match the API's expected input. Here's a refined approach:
1. Ensure that the flow_id
is correctly placed within the filter structure.
2. Double-check the API endpoint and payload structure.
Here's a corrected version of your code snippet:
python
import requests
url = f"{prefect_api_url}/flow_runs/filter"
headers = {
"Content-Type": "application/json"
}
payload = {
"flow_runs": { # Ensure the correct key is used
"flow_id": {
"any_": ["xxyy"]
}
},
"sort": "START_TIME_DESC",
"limit": 20,
"offset": 0,
}
response = <http://requests.post|requests.post>(url, json=payload, headers=headers)
Make sure that the key within the payload matches the expected structure in Prefect's API. If you continue to face issues, you might want to check the Prefect documentation or the GitHub repository for any updates or common issues related to filtering flow runs.
For more detailed information, you can refer to the Prefect documentation and the relevant GitHub source code.