Webhook body parsed as string not object #17140
-
I have an external system that makes a POST request to a Prefect Webhook containing a JSON object. However when I look at the event in Prefect the body is always just appears as a string. Based on this information I was under the impression that the body should be parsed as an object: https://docs.prefect.io/v3/automate/events/webhook-triggers#how-http-request-components-are-handled Is this the expected behaviour or am I making a mistake somewhere? The json that is posted has the following structure:
I have an autoamtion connected ot this webhook and in it I am trying to pull out the individual elements as parameters for the Flow using the Jinja syntax. For example One option I can see is to just pass the whole body as one parameter and then use
but I would prefer to get the body as seperate parameters if possible. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
hi @esisilvestri - this is technically possible today, but the DX is a bit wonky related to #14875 |
Beta Was this translation helpful? Give feedback.
-
Hello @zzstoatzz. Thanks for the feedback. I will try this approach. In the meantime I was able to solve it in another way as well. I managed to get the individual elements into the Webhook Template like so:
Then I was able to access the individual elements in the automation like so The only issue I still had after that was that data can also be a JSON object and with the above approach that comes in as a string that cannot be lloaded with json.loads(). I was however able to use the "ast" libarary to load the resulting string into a Python dictionary and access the values in my Flow: |
Beta Was this translation helpful? Give feedback.
hi @esisilvestri - this is technically possible today, but the DX is a bit wonky
related to #14875