Open StephanHarrer opened 1 week ago
To be more clear:
Here is the relevant part of hook.json:
{
"id": "FS",
"execute-command": "/tmp/test.py",
"command-working-directory": "/tmp",
"pass-arguments-to-command":
[
{
"source": "entire-payload"
}
],
"trigger-rule":
{ "match": { "type": "ip-whitelist", "ip-range": "10.5.5.5/32" } }
},
In that case I receive:
[webhook] 2024/10/13 11:11:45 [e34378] incoming HTTP POST request from 10.5.5.5:23384
[webhook] 2024/10/13 11:11:45 [e34378] FS got matched
[webhook] 2024/10/13 11:11:45 [e34378] error parsing JSON payload invalid character 'd' looking for beginning of value
[webhook] 2024/10/13 11:11:45 [e34378] FSc hook triggered successfully
[webhook] 2024/10/13 11:11:45 [e34378] 200 | 0 B | 86.836µs | 192.168.100.3 | POST /hooks/FS
[webhook] 2024/10/13 11:11:45 [e34378] executing /tmp/test.py (/tmp/test.py) with arguments ["/tmp/test.py" "null"] and environment [] using /tmp/ as cwd
As written above, I think the json format that is passed does not fit. I would therefore like to read in the data as a string and then take care of the further processing myself.
{
"source": "raw-request-body"
}
should give you the complete text as one argument. You'll still get the "error parsing JSON payload" message in the log but that's only happening because the sender that is calling your webhook is sending it with a Content-Type
header that claims it is JSON - the actual execute-command
should still work.
Hello,
I have to handly a webhook from a network system where the content is not json like. Here a example:
date=2024-10-12 time=23:52:08 devid="FGVMEV-CTZXP2_8F" devname="FGVMEV-CTZXP2_8F" eventtime=1728769927878132716 tz="+0200" logid="0100026001" type="event" subtype="system" level="information" vd="root" logdesc="DHCP Ack log" interface="port2" dhcp_msg="Ack" mac="00:XC:29:F4:XX:XX" ip=10.98.0.2 lease=300 hostname="CL" msg="DHCP server sends a DHCPACK"
As far as I see the content is not well json formated.
My question how can I tell webhook to do NOT parse the content as json and handover the string (content) to my python program?
Regards Stephan