Pass parameters to Airflow Experimental REST api when creating dag run

后端 未结 2 798
不思量自难忘°
不思量自难忘° 2020-12-31 10:02

Looks like Airflow has an experimental REST api that allow users to create dag runs with https POST request. This is awesome.

Is there a way to pass parameters via

相关标签:
2条回答
  • 2020-12-31 10:04

    Judging from the source code, it would appear as though parameters can be passed into the dag run.

    If the body of the http request contains json, and that json contains a top level key conf the value of the conf key will be passed as configuration to trigger_dag. More on how this works can be found here.

    Note the value of the conf key must be a string, e.g.

    curl -X POST \
        http://localhost:8080/api/experimental/dags/<DAG_ID>/dag_runs \
        -H 'Cache-Control: no-cache' \
        -H 'Content-Type: application/json' \
        -d '{"conf":"{\"key\":\"value\"}"}'
    
    0 讨论(0)
  • 2020-12-31 10:09

    I had the same issue. "conf" value must be in string

    curl -X POST \
        http://localhost:8080/api/experimental/dags/<DAG_ID>/dag_runs \
        -H 'Cache-Control: no-cache' \
        -H 'Content-Type: application/json' \
        -d '{"conf":"{\"key\":\"value\"}"}'
    
    0 讨论(0)
提交回复
热议问题