You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Airflow REST API dagRuns调用中execution_date_gte参数失效问题

Airflow REST API dagRuns接口execution_date_gte参数不生效的解决办法

问题现象

调用Airflow REST API的/api/v1/dags/{dag_id}/dagRuns接口时,尝试用execution_date_gte参数筛选execution_date大于等于指定时间的DAG运行记录,但参数未生效,返回了早于指定时间的记录。

原执行的curl命令:

curl -X GET 'http://localhost:8080/api/v1/dags/demand_forecast/dagRuns' -H 'Cache-Control: no-cache' -H 'Content-Type: application/json' -d '{"execution_date_gte": "2023-02-02T00:00:00+00:00"}' --user "airflow:airflow"

返回结果包含了execution_date为2022-02-15T00:00:00+00:00的记录,参数未起到筛选作用。

问题原因

Airflow的REST API对于GET类型的接口,不会解析请求体中的参数。用-d参数把筛选条件放在请求体里,接口无法识别这些参数,自然不会执行筛选逻辑。

解决办法

GET请求的筛选参数需要通过**查询字符串(Query String)**传递,正确的curl命令写法如下:

方式1:直接拼接在URL中

curl -X GET 'http://localhost:8080/api/v1/dags/demand_forecast/dagRuns?execution_date_gte=2023-02-02T00%3A00%3A00%2B00%3A00' --user "airflow:airflow" -H 'Cache-Control: no-cache'

方式2:用--data-urlencode自动编码参数

curl -X GET 'http://localhost:8080/api/v1/dags/demand_forecast/dagRuns' --user "airflow:airflow" -H 'Cache-Control: no-cache' --data-urlencode 'execution_date_gte=2023-02-02T00:00:00+00:00'

验证说明

执行上述正确命令后,接口会根据execution_date_gte参数筛选出符合条件的DAG运行记录,不会再返回早于指定时间的结果。

内容的提问来源于stack exchange,提问作者user7727736

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 03:25:49