ncarlier/webhookd

JSON variables

DANW999 opened this issue · 4 comments

Hi there,

Forgive me if I am doing something wrong here. I have a simple script that looks like this:

#!/bin/bash
echo "$action" | tee /tmp/webhook.log

When I start webhookd and trigger the script with the queries in the URL look so curl http://domain:port/script?action=test it works perfectly, however when I try and pass those variables from a JSON structure like so curl -d '{"action":"test"}' -H "Content-Type: application/json" 'http://domain:port/script' it does not work at all, it appears that "action" is not being received as a variable by webhookd. Could I get some help on this please?

Hi,

if you send a body content (JSON or Text), this content is stored inside the script parameter $1.
In order to manipulate this JSON parameter you should use jq.

Webhook parameters are explained here: https://github.com/ncarlier/webhookd#webhook-parameters

You can view a example using JSON here: https://github.com/ncarlier/webhookd/blob/master/scripts/examples/github.sh#L18

Mmm, I do realize that the documentation is misleading because it uses the same foo/bar keyword for the JSON and the query parameter. I will fix that.

Thanks you for your help, I will look into this. And yes it was indeed the documentation I followed so would appreciate that. Thanks again for your works on this project, truly is appreciated.

You're welcome and thank you.