https://prefect.io logo
Title
d

Dekel R

05/04/2023, 3:49 PM
Hey, I’m trying to create a flow run using the API, the flow is created but the agents do not pick it - how do I add a queue and pool name to the request?
curl --location --request POST '<https://api.prefect.cloud/api/accounts/0aceff1b-4fdb-4469-adde-197148a98672/workspaces/b7474c31-4033-449b-96b6-f3544e6f9408/flow_runs/>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer api_key' \
--header 'X-PREFECT-API-VERSION: 0.8.4' \
--data-raw '{
    "name": "testing_api_1",
    "flow_id": "46a211a5-a943-4547-8b4d-8e3c09da68d2",
    "deployment_id": "8507e60e-0a93-43c0-81ba-bd050f0ecd53", "infrastructure_document_id": "5ed25162-53fb-4df5-89bc-426afdc83f41", "state": {"type": "SCHEDULED"}
}'
I looked here https://app.prefect.cloud/api/docs#tag/Flow-Runs - create flow run - but I don’t see any queue and pool params. Thanks
z

Zanie

05/04/2023, 4:00 PM
The work queue / pool is determined by the deployment
d

Dekel R

05/04/2023, 4:05 PM
I’m using the deployment and the infra_doc_id but you can see that the flow triggered by API has no queue or pool (the late one) - then the agent doesn’t pick it up.
z

Zanie

05/04/2023, 4:12 PM
Ah I see
You’ve got the wrong route
You want the one for a deployment flow run
<https://api.prefect.cloud/api/accounts/{account_id}/workspaces/{workspace_id}/deployments/{id}/create_flow_run>
👀 1
@Zach Angell do you remember why we allow
deployment_id
in
FlowRunCreate
? It seems like it should not be allowed to avoid this confusion.
z

Zach Angell

05/04/2023, 4:17 PM
Nope probably just an oversight when we added the
create_flow_run
endpoint for deployments
d

Dekel R

05/04/2023, 4:25 PM
Question - do I even need to pass anything in the request body?
This request works -
curl --location --request POST '<https://api.prefect.cloud/api/accounts/0aceff1b-4fdb-4469-adde-197148a98672/workspaces/b7474c31-4033-449b-96b6-f3544e6f9408/deployments/8507e60e-0a93-43c0-81ba-bd050f0ecd53/create_flow_run>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer api_key' \
--header 'X-PREFECT-API-VERSION: 0.8.4' \
--data-raw '{
    "name": "testing_api_1",
    "infrastructure_document_id": "5ed25162-53fb-4df5-89bc-426afdc83f41", "state": {"type": "SCHEDULED"}
}'
Thanks for the help!! If you can please offer some more examples for curl or even Python Prefect 2 api usages this could help a lot, I couldn’t find anything in this group/in the forums.
j

Jeff Hale

05/20/2023, 4:35 PM
PR with REST examples here thank you for raising@Dekel R!