Dynamic Routes & Asterisk System Command

I have a command that works on the command line:
curl -s https://api.com/getapi -H "Authorization: Basic PASSWORD" -H 'Content-Type: application/json' -d '{"CallingNumber":"${CALLERID(num)}","DialedNumber":"${CALLERID(dnid)}","Keys":"Operator"}' | python2 -c 'import json,sys;obj=json.load(sys.stdin);print obj["result"]'

I am trying to execute it on a dynamic route as an Asterisk command:
${SYSTEM(curl -s https://api.com/getapi -H "Authorization: Basic PASSWORD" -H 'Content-Type: application/json' -d '{"CallingNumber":"${CALLERID(num)}","DialedNumber":"${CALLERID(dnid)}","Keys":"Operator"}' | python2 -c 'import json,sys;obj=json.load(sys.stdin);print obj["result"]')}

I am getting the following error in the Asterisk log:
pbx_functions.c: Can't find trailing parenthesis for function 'SYSTEM(curl -s https://api.com/getapi -H "Authorization: Basic PASSWORD" -H 'Content-Type: application/json' -d '{"CallingNumber":"5555555555","DialedNumber":"6666666666'?

Anyone able to help me figure out what I am not escaping correctly? Thanks!

It looks like you’re running into a character limit for the field, either in dynroutes or in Asterisk. I suggest you use an AGI file like the example in this thread: Using Dynamic Routes with an AGI file

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.