Automations: Deployment parameters from event payload

I have a Prefect Cloud event webhook that creates an Event with a nested JSON object in payload that comes from the webhook body (via ..., "payload": {{body|tojson}}, ... in the webhook template). So far so good (after some trial and error).

Next I want to use an Automation for those events to trigger a deployment, and pass the Event payload as a parameter. I tried:

{
  "myparam": {{event.payload}}
}

But a “parameters must be valid JSON” validation error appears. The deployment parameter is a pydantic model with several other nested models so I’d really rather not explode each parameter individually if there’s a way to pass on the whole object.

{"myparam": "{{event.payload}}"} ends up with the whole object serialised as a string, as does {"myparam": "{{event.payload|tojson}}"}

Help! :slight_smile:

Semi-related, if I edit the Automation in the UI it doesn’t seem to save the JSON template — when I reload or access it via the API it just has ..., "parameters": {}. Updating via the API works, subject to the above.

Hey @rcoup - thanks for this. I cant quite reproduce this behavior and I think there may be a few different routes we can try here. Would you mind getting in touch with me either in the prefect slack community or via email at will at prefect dot io? Thanks.

1 Like

Hi @rcoup - did you resolve this in the end? Interested as I face similar challenge.