Webhook Relay
Search…
URLEncoded Form Data
Webhook Relay automatically parses url encoded form data if Content-Type: application/x-www-form-urlencoded
Webhook Relay detects application/x-www-form-urlencoded requests and automatically parses them so your function can use it. Parsed form data can be accessed through r.RequestFormData variable. For example if the payload looks like this:
1
name=john&lastname=wick
Copied!
Then you can access the form elements and use them to create a new payload:
1
local json = require("json")
2
​
3
local encoded_payload = {
4
name= r.RequestFormData.name[1],
5
lastname=r.RequestFormData.lastname[1]
6
}
7
local encoded_payload, err = json.encode(encoded_payload)
8
if err then error(err) end
9
​
10
r:SetRequestHeader("Content-Type", "application/json")
11
r:SetRequestBody(encoded_payload)
Copied!
This would transform the webhook into:
1
{
2
"name": "john",
3
"lastname": "wick"
4
}
Copied!

Nested forms

If your form contains nested fields such as &campaign%5Bid%5D=98 you can access them directly as well:
1
r:SetRequestBody(r.RequestFormData["campaign[id]"][1])
Copied!
Copy link
Contents
Nested forms