I'm using Bicom PBXware. I have complex cURL with headers to send using -H which means I can not use Asterisk CURL app. So I created bash script which works properly:
/opt/pbxware/pw/var/lib/asterisk/agi-bin # cat resp_example.sh
#!/bin/bash
resp=`/usr/bin/curl -s -H "Content-Type: application/json" -H "Card: 512912***" -H "Exp: 1125" -H "user: [email protected]" -H "Username: ***" -H "Api_token: ***" -X POST https://somewebsite/apiivr/getbalance`
#resp='{"result":true,"balance":"4315.94","message":"ok"}'
echo "SET VARIABLE resp '---> $resp'"
echo "NoOp resp: $resp"
so this bash script works perfectly from Linux CLI, but fails from dialplan:
exten => 2006,1,AGI(resp_example.sh)
same => n,Hangup
I chmoded all to 777 but it still fails:
/opt/pbxware/pw/var/lib/asterisk/agi-bin # ls -lah
total 260K
drwxrwxrwx 2 root root 4.0K Sep 1 09:06 .
drwxr-xr-x 14 555 555 4.0K Sep 1 10:51 ..
-rwxrwxrwx 1 root root 100 Aug 31 05:51 CC-balance-process.agi
-rwxrwxrwx 1 root root 287 Sep 1 08:21 CCsetvars.agi
-rwxrwxrwx 1 root root 1.3K Sep 1 09:17 CCtest.agi
-rwxrwxrwx 1 555 555 1.3K Aug 31 16:59 CCtest.sh
-rwxrwxrwx 1 root root 1.8K Jan 17 2010 agi-test.agi
-rwxrwxrwx 1 root root 88K Jan 17 2010 eagi-sphinx-test
-rwxrwxrwx 1 root root 122K Jan 17 2010 eagi-test
-rwxrwxrwx 1 root root 15K Jan 17 2010 jukebox.agi
-rwxrwxrwx 1 root root 430 Sep 1 10:17 resp_example.sh
First of all you should check that asterisk user ABLE run that script(including directory access)
After that, you have to debug for errors.
ps Note, asterisk HAS internal func_CURL