Paymahn Moghadasian
Paymahn Moghadasian

Reputation: 10329

405 error when getting Airflow dag runs through rest api

I'm trying to use the airflow REST api (v1.10.2) but I'm having problems any time I try to query information about a specific dag.

Here's an example of the latest_runs endpoint working:

 ❯❯❯ curl -X GET http://192.168.99.100:30080/api/experimental/latest_runs
{
  "items": [
    {
      "dag_id": "test_dag",
      "dag_run_url": "/admin/airflow/graph?dag_id=test_dag&execution_date=2019-03-07+21%3A18%3A23.387031%2B00%3A00",
      "execution_date": "2019-03-07T21:18:23.387031+00:00",
      "start_date": "2019-03-07T21:18:23.683240+00:00"
    }
  ]
}

However, when I try to query test_dag I get an error:

 ❯❯❯ curl -X GET "http://192.168.99.100:30080/api/experimental/dags/test_dag/dag_runs"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>

I've also tried looking in the source code and I found that there's a state param that can be used:

 ❯❯❯ curl -X GET "http://192.168.99.100:30080/api/experimental/dags/test_dag/dag_runs?state=success"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>

but adding that in doesn't seem to help.

I find that triggering a DAG works:

 ❮❮❮ curl -X POST \
  http://192.168.99.100:30080/api/experimental/dags/test_dag/dag_runs \
  -H 'Content-Type: application/json' \
  -d '{}'
{
  "message": "Created <DagRun test_dag @ 2019-03-07 22:31:18+00:00: manual__2019-03-07T22:31:18+00:00, externally triggered: True>"
}

Anyone have an idea why I can't query the status of a DAG and get a 405?

EDIT: here's some more investigation. I tried using all of the possible methods, none of which succeed:

 4:21PM /Users/paymahn/solvvy/scheduler  ✘ 130 train.models ✭ ✱ ◼
 ❯❯❯ curl -X GET "http://192.168.99.100:30080/api/experimental/dags/test_dag/dag_runs"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>
 4:21PM /Users/paymahn/solvvy/scheduler train.models ✭ ✱ ◼
 ❯❯❯ curl -X OPTIONS "http://192.168.99.100:30080/api/experimental/dags/test_dag/dag_runs"
 4:21PM /Users/paymahn/solvvy/scheduler train.models ✭ ✱ ◼
 ❯❯❯ curl -X TRACE "http://192.168.99.100:30080/api/experimental/dags/test_dag/dag_runs"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>
 4:22PM /Users/paymahn/solvvy/scheduler train.models ✭ ✱ ◼
 ❯❯❯ curl -X PATCH "http://192.168.99.100:30080/api/experimental/dags/test_dag/dag_runs"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>
 4:22PM /Users/paymahn/solvvy/scheduler train.models ✭ ✱ ◼
 ❯❯❯ curl -X DELETE "http://192.168.99.100:30080/api/experimental/dags/test_dag/dag_runs"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>
 4:22PM /Users/paymahn/solvvy/scheduler train.models ✭ ✱ ◼
 ❯❯❯ curl -X HEAD "http://192.168.99.100:30080/api/experimental/dags/test_dag/dag_runs"
Warning: Setting custom HTTP method to HEAD with -X/--request may not work the
Warning: way you want. Consider using -I/--head instead.
curl: (18) transfer closed with 178 bytes remaining to read
 4:22PM /Users/paymahn/solvvy/scheduler  ✘ 18 train.models ✭ ✱ ◼
 ❯❯❯ curl -X PUT "http://192.168.99.100:30080/api/experimental/dags/test_dag/dag_runs"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>
 4:22PM /Users/paymahn/solvvy/scheduler train.models ✭ ✱ ◼
 ❯❯❯ curl -X POST "http://192.168.99.100:30080/api/experimental/dags/test_dag/dag_runs"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not understand.</p>

Upvotes: 4

Views: 3950

Answers (1)

Related Questions