How to process GET parameters from HTTP endpoint in a flow #5665
-
Hey I have problems looping GET parameters through a flow. I know that I must use a pre-processor before the INPUT node (according to https://www.windmill.dev/docs/core_concepts/preprocessors). But thats it. Doc doesnt really reveal how and where to access GET parameters, vibe coding also doesnt really helped. I don't even know where to start and what to ask, tbh. That's what I got so far:
def preprocessor(
# Trigger metadata
wm_trigger: WmTrigger = None,
):
# Initialize foobar with default value
foobar = ""
# Check if wm_trigger exists and then extract foobar from query parameters
if wm_trigger is not None and wm_trigger.get("kind") in ("http", "webhook"):
http_data = wm_trigger.get("http")
if http_data is not None and "query" in http_data:
foobar = http_data["query"].get("foobar", "")
return {
"foobar": foobar
# return the args to be passed to the runnable
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"foobar": {
"description": "",
"type": "object"
}
},
"required": [],
"type": "object",
"order": [
"fooobar"
]
} rest of the flow is probably not relevant.. as it seems like the information stuck somewhere between the HTTP endpoint and the INPUT node. (When I test the flow and add dummy content, it's being passed through to the end) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
We are refactoring to preprocessors soon to make it a bit easier, but my advice would be to deploy a flow where preprocessor return the entire wm_trigger and look at your flow_input to find the args you are interested in. Then adjust your preprocessor accordingly. |
Beta Was this translation helpful? Give feedback.
-
Good advice, got it. Doc is a little misleading I'd say. There's no "kind" attriibute in the windmill object. In short, one can referer to the query parameters like that (ofc you should buy tests around it): def preprocessor(
wm_trigger: WmTrigger = None,
):
return {
"foobar": wm_trigger["http"]["query"]["foobar"]
# return the args to be passed to the runnable
} |
Beta Was this translation helpful? Give feedback.
We are refactoring to preprocessors soon to make it a bit easier, but my advice would be to deploy a flow where preprocessor return the entire wm_trigger and look at your flow_input to find the args you are interested in. Then adjust your preprocessor accordingly.