I am trying to trigger airflow dags with REST API. It does not work. I get an ERROR 400 with response:
{
"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"
}
I tried it via CURL and with Python requests module and results are the same.
Example:
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))
Do I need to specify something in Airflow config or in Dag to make it possible to run it?
Because as I understand there is something with permissions ?
"Property is read-only - 'state'",