Skip to main content

What is the best way to parse a RestApi call in Dialplan with TL

Posted by aponnath on Sat, 12/12/2020

I am wondering if anyone has used a RESTApi call via curl in a ThirdLane dial plan and then parsed the result into variables. So far i have had limited success as some of the libary's require to be compiled into the asterisk kernel and i dont want to touch that if i dont have to for now.

I tried something like this using jq but not much luck, my curl works

exten => s,n,NoOp('This is called before we call block section')
exten => s,n,NoOp(${CALLER_NUMBER})
exten => s,n,NoOp(${CALLEE_NUMBER})
exten => s,n,Set(CURL_RESULT=${CURL(http://192.168.1.100/blacklist/${CALLEE_NUMBER}/${CALLER_NUMBER})})
exten => s,n,Set(result=${SHELL(echo '${CURL_RESULT}' | jq '.status')})
exten => s,n,NoOp(${result})