How to trigger an Airflow DAG via API using curl

480 views Asked by At

I'm currently able to use the API on a standalone instance of Airflow, and I get a successful response when getting a DAG description with:

curl -X GET 'localhost:8080/api/v1/dags/my_dag' -H 'Content-Type: application/json' --user "admin:thepassword"

The problem is when I try to trigger the same dag using:

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

That returns this response:

{
  "detail": "None is not of type 'object'",
  "status": 400,
  "title": "Bad Request",
  "type": "https://airflow.apache.org/docs/apache-airflow/2.3.2/stable-rest-api-ref.html#section/Errors/BadRequest"
}

I suppose my curl call is wrong, but I can't find what it is.

1

There are 1 answers

3
Thomas On BEST ANSWER

You're not providing a payload/body in your request. You can do this with the -d flag.

API reference.

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