POST REQUEST Help -- Flow run failed. Error: POST body missing. Did you forget use body-parser middleware?

Good Afternoon,

I am trying to run a deployment via the REST API but I repeatably get the following error:Flow run failed. Error: POST body missing. Did you forget use body-parser middleware?

This is my code:

import requests

base_url = "https://api.prefect.cloud/api/accounts/myaccountid/workspaces/myworkspaceid
token = "mytoken"
deployment_id = "mydeploymentid"

def create_flow_run(deployment_id, base_url, token):
    url = f"{base_url}/deployments/{deployment_id}/create_flow_run"
    headers = {
        "Content-Type": "application/json",
        "Authorization": f"Bearer {token}",
    }
    data = {}  # Add your request body here
    response = requests.post(url, headers=headers, json=data)
    return response

r = create_flow_run(deployment_id, base_url, token)
print(r.status_code)
print(r.text)

Any help would be greatly appreciated!

Hmm, I don’t see anything directly incorrect with how you’re attempting this call.

Could you provide the full stacktrace here? are you using cloud or self-hosted server?

As an aside, if you don’t mind having prefect available at runtime you can use prefect.deployments.run_deployment to simplify this.