i get the desired response and the value i am looking for. What am i missing here or is there a better way to parse values into the dialplan from a RestAPI call.
I am running on Asterisk 13.32.0 , CentOs 6 and jq-1.5
This doesn’t work either and wouldn’t be the ideal solution as i want to be able to assign multiple call variables based on the curl response.
But i tried use …
there shouldn’t be a new line when you use jq as it should read and return only the value of the key specified. I am suprised that json is not in higher demand in the astrisk community.
So how would i go about troubleshooting why it doesn’t not return anything. We know if i uonly run the curl i get data. when i use the jq i get nothing. if i use jq from my commandline on server i get what i expect
-- Executing [s@get-country-code:1] NoOp("SIP/101-000001cc", "Getting country name...") in new stack
-- Executing [s@get-country-code:2] Set("SIP/101-000001cc", "country=US") in new stack
-- Executing [s@get-country-code:3] NoOp("SIP/101-000001cc", "Country code is: US") in new stack
-- Executing [s@get-country-code:4] Hangup("SIP/101-000001cc", "") in new stack
Thanks, i am missing something which causes this to fail. I used your sample code in my dial plan
exten => s,n,Set(country=${SHELL(curl -s ipinfo.io | jq .'country'):1:-2})
exten => s,n,Noop(Country code is: ${country})
and got the following result
-- Executing [s@macro-tl-custom-userexten:78] Set("SIP/2WAY-00000060", "country=") in new stack
-- Executing [s@macro-tl-custom-userexten:79] NoOp("SIP/2WAY-00000060", "Country code is: ") in new stack
Just to test i run it with
exten => s,n,Set(country=${SHELL(curl -s ipinfo.io}) i get the whole json doc so we know curl is not the issue but it seems to be the issue running jq from within dialplan