Post Request in extension.conf file

Hello there,

How to send a POST request using CURL in extension.conf file?

I try
exten => _21X,1,Verbose(0, ${CURL -X POST (http://localhost:4000/${EXTEN})}). But this didn’t work.

You cannot execute any application inside the verbose() application as this is only for debug purposes, use curl ini its own dial plan line

Verbose isn’t special. Side effects of functions in its arguments will still be effective.

Arguments are expanded before the application is run. Although I haven’t tried it, I suspect even the application name can be evaluated at run time.

What will be an issue here is that there is no function called "CURL -X POST ", and this is not how you do CURL posts, according to the wiki:

You re right I didnt check he using the Linux curl command instead of the asterisk curl function, if this is the case you will need to use shell or system function related to run funciton inside verbose thanks for that clarification

Thank you everyone
As I am new to asterisk, Can anyone tell me what should I exactly write in the dial plan to execute POST request from remote server?

Use the post-data option on curl

So I use
exten => _21X,1,CURL(http://localhost:4000/${EXTEN}, { "key": "1"})

It doesn’t work.
Please correct me where did I mistake

Hello @jay.sojitra,

Use this syntax:

exten => _21X,1,System(curl -m 2 -d "exten=${EXTEN}" -X POST http://localhost:4000)

Thank you,

Daniel Friedman
Trixton LTD.

1 Like

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