How to use SimpleHttpOperator in Airflow

Viewed 3657

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': ['ss@asd.com'],
    '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

1 Answers

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

Related