Does `StartFlowRun` support passing parameters as ...
# ask-community
e
Does
StartFlowRun
support passing parameters as lists of dictionaries in Python? I am currently getting the following error when I try to do that:
Copy code
prefect.exceptions.ClientError: 400 Client Error: Bad Request for url: <https://api.prefect.io/>
This is likely caused by a poorly formatted GraphQL query or mutation but the response could not be parsed for more details
I tried performing the same operation via the interactive graphql api and I needed to escape the
{
and
"
to get the query to work. Looking at the source it seems as though this doesn’t happen and might be the cause of my problem.
I’ve changed my approach to avoid this problem, but would be interested to hear whether that’s the case
k
Hey @Eddie Atkinson, I believe this should work. If you got it to work in the interactive API, there should be a way to get it to work with Python (syntax might just differ a bit). I’ll give this a shot later
e
Cheers Kevin!
k
Oh sorry, support was kinda busy. If you don’t hear from me tom, feel free to ping
This worked for me:
Copy code
from prefect import task, Flow, Parameter
import prefect

@task
def abc(x):
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>(x)
    return x

with Flow(name="betfair_flow") as flow:
    x = Parameter("x")
    abc(x)

flow.register("dsdc")

from prefect.tasks.prefect import StartFlowRun
import json

test = [{'id': 123, 'data': 'qwerty', 'indices': [1,10]}, {'id': 345, 'data': 'mnbvc', 'indices': [2,11]}]
StartFlowRun(project_name="dsdc", flow_name="betfair_flow").run(parameters={"x": json.dumps(test)})
e
Interesting, I must have done something weird. Thanks Kevin!
k
Hi! @Kevin Kho - and if one want to pass json as parameter but run via CLI?
k
See this