I am trying to use Prefect 2.3.1's REST API to cre...
# prefect-community
j
I am trying to use Prefect 2.3.1's REST API to create flow run (locally installed prefect server), but irrespective what I've tried, flow is never scheduled. I guess that the root cause is that I can't get it assigned to a work_queue. But I haven't been able to pass it, and I believe that it should come from the deployment. Flow works ok, when I run it from UI. Any ideas what detail I'm missing? I create a request:
Copy code
curl -X 'POST' \
  '<http://localhost:4200/api/flow_runs/>' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "my-flow-run",
  "flow_id": "adc10e6b-62b1-4a5a-ba75-a9d03107c75c",
  "deployment_id": "0a26b313-0134-43ac-b4ab-67bcbeeaebf9",
  "parameters": { "flow_run_id": "d3f49714-3b14-4bbf-a42c-7081149b9fb3" }
}'
and get a response:
Copy code
{
  "id": "1277b255-4250-45f7-b0bf-c06630dcac86",
  "created": "2022-09-05T07:51:42.448486+00:00",
  "updated": "2022-09-05T07:51:42.450190+00:00",
  "name": "my-flow-run",
  "flow_id": "adc10e6b-62b1-4a5a-ba75-a9d03107c75c",
  "state_id": "aae8e698-9df6-4efa-8692-2d9e97e01112",
  "deployment_id": "0a26b313-0134-43ac-b4ab-67bcbeeaebf9",
  "work_queue_name": null,
...
1
E.g. here are two flows, where the other one I tried to start with a "Scheduled" state.
a
Great question, setting the state to scheduled is what's missing, this post will answer your question https://discourse.prefect.io/t/how-to-trigger-a-flow-run-from-a-deployment-via-api-call-using-python-requests-library-or-from-a-terminal-using-curl/1396
💯 1