<@ULVA73B9P> I have setup a webhook that parses in...
# ask-marvin
a
@Marvin I have setup a webhook that parses information in the template, i.e. {"resource":{"myinfo":"123"}}. I have added an automation that is triggering a deployment whenever that webhook happens. I would like to have
myinfo
as a parameter to that deployment, but I don't know how to get it in the "actions". I can have
{{event.payload}}
to get the whole payload, but I would expect that
{{event.resource.myinfo}}
would get me my
myinfo
data, but I get an empty parameter
m
When setting up webhooks in Prefect 2.x, if the
Content-Type
of the request is
application/json
, the body will be parsed as a JSON object and become available for use in webhook templates. Similarly, if the
Content-Type
is
application/x-www-form-urlencoded
, the body will be parsed into a dictionary-like object of key-value pairs. In the context of automation actions in Prefect, you can use Jinja2 templates to access the parsed JSON payload. Jinja2 supports both index and attribute access to fields, which means you should be able to access nested fields using the dot notation like you proposed:
{{ event.payload.resource.myinfo }}
. The issue you are experiencing with extracting
myinfo
using
{{ event.resource.myinfo }}
and getting an empty parameter might be related to how the data is structured within the event payload or a misconfiguration in your webhook or automation action. If
{{ event.payload }}
gives you the whole payload, then your approach of
{{ event.payload.resource.myinfo }}
seems syntactically correct for accessing the
myinfo
field, assuming that
resource
is a top-level key in the payload and
myinfo
is nested within. Here's what you can try: 1. Double check the JSON structure of the incoming payload to ensure the keys are named correctly. 2. Confirm that the
Content-Type
of the incoming webhook request is set to
application/json
. 3. Ensure that the Prefect automation is properly configured to parse and use the JSON payload. If you continue to face issues, please provide more details about the JSON structure of your payload and the automation configuration, and I can look further into the matter.