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

通过curl调用Airflow API触发DAG时出现400错误,请求格式待排查

问题解决:Airflow API触发DAG返回400 Bad Request错误

错误原因

Airflow 2.x的/api/v1/dags/{dag_id}/dagRuns POST接口要求请求必须携带JSON格式的请求体,接口期望接收一个object类型的参数。你当前的curl命令没有传递任何请求体,导致服务端接收到None,不符合参数类型要求,因此返回"None is not of type 'object'"的错误。

修复后的curl命令

1. 无参数触发DAG

只需传递一个空的JSON对象即可满足接口要求:

curl -X POST 'localhost:8080/api/v1/dags/my_dag/dagRuns' \
-H 'Content-Type: application/json' \
--user "admin:the_password" \
-d '{}'

2. 带自定义参数触发DAG

如果需要指定执行时间、传递任务参数等,可以在请求体中添加对应字段:

curl -X POST 'localhost:8080/api/v1/dags/my_dag/dagRuns' \
-H 'Content-Type: application/json' \
--user "admin:the_password" \
-d '{
  "execution_date": "2024-05-20T00:00:00+00:00",
  "conf": {
    "param1": "value1",
    "param2": "value2"
  }
}'

额外注意点

检查你的认证密码:GET请求中使用的是admin:thepassword,POST请求中是admin:the_password,两者存在字符差异,确认是否为笔误,避免因密码错误导致的认证失败。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 07:13:29