我正在尝试使用 REST API 触发气流 dags。这没用。我得到一个 ERROR 400 的响应:
{
"detail": "Property is read-only - 'state'",
"status": 400,
"title": "Bad Request",
"type": "https://airflow.apache.org/docs/2.0.1/stable-rest-api-ref.html#section/Errors/BadRequest"
}
我通过 CURL 和 Python requests 模块尝试过,结果是一样的。
例子:
import requests
headers = {
'accept': 'application/json',
'Content-Type': 'application/json',
}
auth = ('test', 'test')
import json
body = {
"conf": {},
"dag_run_id": "string",
"execution_date": "2021-04-15T14:04:43.602Z",
"state": "success"
}
req = requests.post("http://127.0.0.1:8080/api/v1/dags/sleeper/dagRuns",
headers=headers, auth=auth, data=json.dumps(body))
我是否需要在 Airflow 配置或 Dag 中指定某些内容才能运行它?因为据我所知,有些东西是有权限的?
"Property is read-only - 'state'",