Problem with curl from dialplan

Hi guys!

I need parse curl result in my dialplan, and I have problem:

My dialplan:

[sub-ASRTEST]
exten => s,1,Noop(-------------------------------------------------------------ASR TEST -----------------------------)
        same => n,Set(SR-FILENAME=/tmp/SR-${CALLERID(num)}-${UNIQUEID}.wav)
        same => n,Record(${SR-FILENAME},3,30)
        same => n,Noop(--------------------Test -----------------------------)
        same => n,Set(wynik=${SHELL(curl -X POST "http://someweb.some.pl:9000/upload" -H "accept:application/json" -H "Content-Type: multipart/form-data" -F "file=@${SR-FILENAME};type=audio/wav")})
        same => n,NoOp(result is ${wynik})
        same => n,noop(----------------------------------------------------------------------------------------------)
        same => n,Return

When I execute curl in system shell “curl -X POST “http://someweb.some.pl:9000/upload” -H “accept:application/json” -H “Content-Type: multipart/form-data” -F “file=@${SR-FILENAME};type=audio/wav””
I got answer:

{“file”:“SR-100-1677604067.5.wav”,“message”:“SUCCESS”,“transcript”:[{“end_in_s”:4.0,“start_in_s”:0.0,“text”:" Hello my name is Paul."}]}

But from dialplan, I receive error like that:

[2023-03-01 12:45:01] WARNING[21872][C-00000025]: pbx_variables.c:756 pbx_substitute_variables_helper_full_location: Error in extension logic (missing ‘}’)
[2023-03-01 12:45:01] WARNING[21872][C-00000025]: pbx_functions.c:460 func_args: Can’t find trailing parenthesis for function ‘SHELL(curl -X POST “http://someweb.some.pl:9000/upload” -H “accept:application/json” -H “Content-Type: multipart/form-data” -F "file=@/tmp/SR-100-1677671090.36.wav’?

I found similar topic here: [SHELL + cURL In Dialplan - #3 by comtech]
But those solution doesn’t work.

What happens when you escape the semicolon?

It is better because i dont get error
But this semicolon is important. How to put it in anyway ? :sweat_smile:

You escape it as ; is a comment for Asterisk. You escape it by doing \;

${SHELL(curl -X POST "http://someweb.some.pl:9000/upload" -H "accept:application/json" -H "Content-Type: multipart/form-data" -F "file=@${SR-FILENAME}\;type=audio/wav")}
2 Likes

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