Tiago Serafim
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!12 replies