GitHub user nrobinson-intelycare closed the discussion with a comment: Getting 
400 when using airflow rest api to trigger airflow dag

@potiuk

I have a suspicion this is a poorly handled error from `dag.create_dagrun`:
https://github.com/apache/airflow/blame/main/airflow/api_fastapi/core_api/routes/public/dag_run.py#L371

Switching up the request body yields some interesting responses.

```
curl \
--url http://AIRFLOW_HOST:8080/api/v1/dags/manual_dbt_airflow_run_batch/dagRuns 
\
--user 'API_USER:API_PASSWORD' \
-H 'Content-Type: application/json' \
-d '{"run_id":"", "dag_id":"", "run_type":""}'

{
  "detail": "Property is read-only - 'dag_id'",
  "status": 400,
  "title": "Bad Request",
  "type": 
"https://airflow.apache.org/docs/apache-airflow/2.10.4/stable-rest-api-ref.html#section/Errors/BadRequest";
}
```



```
curl \
--url http://AIRFLOW_HOST:8080/api/v1/dags/manual_dbt_airflow_run_batch/dagRuns 
\
--user 'API_USER:API_PASSWORD' \
-H 'Content-Type: application/json' \
-d '{"run_id":""}'

{
  "detail": "{'dag_id': ['Missing data for required field.'], 'run_type': 
['Missing data for required field.'], 'logical_date': ['Unknown field.'], 
'dag_run_id': ['Unknown field.']}",
  "status": 400,
  "title": "Bad Request",
  "type": 
"https://airflow.apache.org/docs/apache-airflow/2.10.4/stable-rest-api-ref.html#section/Errors/BadRequest";
}
```

```
curl \
--url http://AIRFLOW_HOST:8080/api/v1/dags/manual_dbt_airflow_run_batch/dagRuns 
\
--user 'API_USER:API_PASSWORD' \
-H 'Content-Type: application/json' \
-d '{"run_id":null, "logical_date":"2025-01-15T21:31:12Z"}'

{
  "detail": "{'run_id': ['Field may not be null.'], 'dag_id': ['Missing data 
for required field.'], 'run_type': ['Missing data for required field.'], 
'logical_date': ['Unknown field.'], 'dag_run_id': ['Unknown field.']}",
  "status": 400,
  "title": "Bad Request",
  "type": 
"https://airflow.apache.org/docs/apache-airflow/2.10.4/stable-rest-api-ref.html#section/Errors/BadRequest";
}
```

Is this a known issue on the roadmap?

GitHub link: 
https://github.com/apache/airflow/discussions/45539#discussioncomment-11848048

----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscr...@airflow.apache.org

Reply via email to