Tiago Serafim
Tiago Serafim16mo ago

Using QueryString params inside a POST webhook

Hey all, I'd like to suggest adding to the webhook handling a way to include the payload parameter on POSTs requests. This parameter would be passed to the script that accepts POST requests, merging the payload from the query string with the JSON data from the POST request. Example For example, a request might look like this: /api/w/admins/jobs/run_wait_result/p/u/user/undisputed_script?include_header=X-Sign,foo&payload=${encodeURIComponent(btoa(JSON.stringify({id: 42})))} In this case, the payload parameter from the query string would be combined with the JSON data from the POST request, making both available inside the webhook. Motivation I'm working on an async service that runs on Lambda. This service accepts a webhook that is POSTed to when the service completes. Here's a typical use case: 1. Inside a flow, I call a third-party API, specifying another script as the webhook endpoint. 2. The flow is suspended. 3. The specified script is eventually called, receiving the ID of the suspended job in its payload query string. 4. The script verifies the signature using the X-Sign header and resumes the flow using its ID by calling JobService.resumeSuspendedFlowAsOwner. Alternatives If merging the payload seems too confusing, we might consider another approach, such as adding an argument like qs=true. This would pass down all the query string data to the POST script without merging it with the JSON. I asked about this issue couple of weeks ago and I thought I understood the proposed alternative, but I couldn't figure out how to work with the suspended flow and another script without somehow using a storage to map the resume URL with a job_id returned by the service. I am still not sure if I'm missing something obvious about this issue. Thanks again!
7 Replies
rubenf
rubenf16mo ago
Sorry it might be a dumb question but what prevents you from passing that part of the payload in the json body ?
Tiago Serafim
Tiago SerafimOP16mo ago
Not dumb at all. I use an third party tool (Remotion) that has this webhook feature and the lambda is built by them, and unless I fork there's no way to modify the JSON body. ( https://www.remotion.dev/docs/lambda/webhooks ).
Webhooks | Remotion | Make videos programmatically in React
When rendering on AWS Lambda, Remotion can send webhooks to notify you when the render ends, successfully or with failures. This page describes the webhook payloads and how to set up a webhook API endpoint.
rubenf
rubenf16mo ago
something I don't follow from their documentation, the webhook itself is a parameter of the request you are doing ?
rubenf
rubenf16mo ago
renderMediaOnLambda() | Remotion | Make videos programmatically in ...
Kicks off a render process on Remotion Lambda. The progress can be tracked using getRenderProgress().
Tiago Serafim
Tiago SerafimOP16mo ago
Yes. Basically I call renderOnLambda(..., webhookUrl).
rubenf
rubenf16mo ago
you are deploying this on lambda right ? could you do the transformation with another lambda ? your feature request is not wrong but would prefer to unblock you and put that at the end of backlog and by transformation on another lambda, I mean send the parameter in the query to the lambda, and the lambda then call windmill by passing everything in the body
Tiago Serafim
Tiago SerafimOP16mo ago
Thank you so much and sorry for the trouble of having you read other docs. Yes, that would work! Thanks! I understand and don't need you to prioritize this, as I'm not aware of any other tool that uses webhooks like this. And there's this alternative of wrapping the lambda or using a storage to map the IDs between the flow / script.