小编Jak*_*uta的帖子

如何使用 REST API 触发气流 dag(我收到“属性是只读的 - '状态'”,错误)

我正在尝试使用 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"
}
Run Code Online (Sandbox Code Playgroud)

我通过 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))
Run Code Online (Sandbox Code Playgroud)

我是否需要在 Airflow 配置或 Dag 中指定某些内容才能运行它?因为据我了解,有一些具有权限的东西? "Property is read-only - 'state'",

rest directed-acyclic-graphs python-3.x airflow airflow-api

4
推荐指数
1
解决办法
9989
查看次数