Aseem
Aseem

Reputation: 6787

How to use SimpleHttpOperator in Airflow

I get error : http_conn_id http_default isnt defined when I run following code:

default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'start_date': datetime(2020, 2, 27),
    'email': ['[email protected]'],
    'email_on_failure': True,
    'email_on_retry': True,
    'retries': 1,
    'retry_delay': timedelta(seconds=5),
}
dag = DAG(
    'dag1',
    default_args=default_args,
    description='A simple tutorial DAG',
    schedule_interval='@daily',
)
t2 = SimpleHttpOperator(
    task_id='get_labrador',
    method='GET',
    http_conn_id='http_default',
    endpoint='api/breed/labrador/images',
    headers={"Content-Type": "application/json"},
    xcom_push=True,
    dag=dag
)

What should be my http_conn_id value. thanks

Upvotes: 5

Views: 6459

Answers (1)

kaxil
kaxil

Reputation: 18884

http_conn_id should contain the name of the Airflow Connection that contains the detail of the url you want to connect to. For example the Hostname to send to Slack Webhook would be https://hooks.slack.com/

enter image description here

Upvotes: 4

Related Questions