ARI channels list from curl

I try to try the example in:

wiki.asterisk.org/wiki/display/ … d+with+ARI

it work fine, but when I tried to do (I would channels list):

curl -v -u asterisk:asterisk -X POST “http://192.168.56.12:8088/ari/channels

I receive:

[code]* About to connect() to 192.168.56.12 port 8088 (#0)

  • Trying 192.168.56.12…
  • Adding handle: conn: 0x7ff4c900c000
  • Adding handle: send: 0
  • Adding handle: recv: 0
  • Curl_addHandleToPipeline: length: 1
    • Conn 0 (0x7ff4c900c000) send_pipe: 1, recv_pipe: 0
  • Connected to 192.168.56.12 (192.168.56.12) port 8088 (#0)
  • Server auth using Basic with user ‘asterisk’

POST /ari/channels HTTP/1.1
Authorization: Basic YXN0ZXJpc2s6YXN0ZXJpc2s=
User-Agent: curl/7.30.0
Host: 192.168.56.12:8088
Accept: /

< HTTP/1.1 400 Bad Request

  • Server Asterisk/13.1.0 is not blacklisted
    < Server: Asterisk/13.1.0
    < Date: Sun, 08 Feb 2015 12:56:37 GMT
    < Cache-Control: no-cache, no-store
    < Content-type: application/json
    < Content-Length: 45
    <
    {
    “message”: “Endpoint must be specified”
  • Connection #0 to host 192.168.56.12 left intact[/code]

So, I tried:

curl -v -u asterisk:asterisk -X POST -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ -H ‘User-Agent: php-ari’ -d ‘{“endpoint”: “local/1”}’ “http://192.168.56.12:8088/ari/channels

[code]* About to connect() to 192.168.56.12 port 8088 (#0)

  • Trying 192.168.56.12…
  • Adding handle: conn: 0x7faa14003a00
  • Adding handle: send: 0
  • Adding handle: recv: 0
  • Curl_addHandleToPipeline: length: 1
    • Conn 0 (0x7faa14003a00) send_pipe: 1, recv_pipe: 0
  • Connected to 192.168.56.12 (192.168.56.12) port 8088 (#0)
  • Server auth using Basic with user ‘asterisk’

POST /ari/channels HTTP/1.1
Authorization: Basic YXN0ZXJpc2s6YXN0ZXJpc2s=
Host: 192.168.56.12:8088
Content-Type: application/json
Accept: application/json
User-Agent: php-ari
Content-Length: 23

  • upload completely sent off: 23 out of 23 bytes
    < HTTP/1.1 400 Bad Request
  • Server Asterisk/13.1.0 is not blacklisted
    < Server: Asterisk/13.1.0
    < Date: Sun, 08 Feb 2015 12:58:25 GMT
    < Cache-Control: no-cache, no-store
    < Content-type: application/json
    < Content-Length: 61
    <
    {
    “message”: “Application or extension must be specified”
  • Connection #0 to host 192.168.56.12 left intact[/code]

What do I mistake?

thanks

I tried with php script:

[code]$url = “http://192.168.56.12:8088/ari/channels”;
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);

//curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERPWD, “asterisk:asterisk”);

// Execute
$result=curl_exec($ch);

print “error:” . curl_error($ch) . “
”;
print “out:” . $result . “
”;
// Closing
curl_close($ch);[/code]

and I obtained:

So it’s work fine, why by curl from linux command it don’t work?
thanks

I think your curl command was doing a POST request but your php curl code is doing a GET request?