mod_curl Whitespace

Status
Not open for further replies.

dandickson

New Member
Jan 15, 2020
8
1
3
I'm using mod_curl to send a get request to an external API using a URL similar to this:

https://api.sample.com/webhook/office-inbound-call?site=samplesite&callernum=${caller_id_number}&callerid=${caller_id_name}

It's mostly working just fine however as the ${caller_id_name} has spaces in it, rather than converting to %20 curl is just ending the request, i'm able to catch the caller ID name prior to the first space but nothing after.

My thought here is to pipe ${caller_id_name} into a new variable, ie ${caller_id_name_api} and run a replace on that variable to change spaces to %20 prior to consuming it in the curl action.

Has anyone done anything like this before?

Thanks
 

dandickson

New Member
Jan 15, 2020
8
1
3
I ended up just doing this in lua, I was able to add the extra quotes I needed without causing a dialplan error:

if (session:ready()) then
session:execute("curl", "API_ADDRESS" .. " post site=SITE&callernum=" ..session:getVariable("caller_id_number") .. "&callerid='" ..session:getVariable("caller_id_name") .. "'");
end
 

dandickson

New Member
Jan 15, 2020
8
1
3
I created a lua file in the /usr/share/freeswitch/scripts with my code block and then referenced the lua from my dial plan like:

Code:
<action application="lua" data="call_post.lua"/>
 
Status
Not open for further replies.