Create a call beetwen 2 extensions via ARI (REST)


#1

Hi to everybody,

I am new using Asterisk, and I have a problem to establish a call beetwen peers (extensions). I am not sure if I am perform the steps properly and in order. I need to create the channel without use originate, because I need to take the control of each id and action.

1. mydomain/ari/channels/create?api_key=user:pass (POST)
with :
endpoint : PJSIP/ext1
extension : ext2
channelId: canal1
app: hello-world

2. mydomain/ari/channels/create?api_key=user:pass (POST)
with :
endpoint : PJSIP/ext2
extension : ext1
channelId: canal2
app: hello-world
3. mydomain/ari/bridges?api_key=user:pass (POST)
with :
bridgeId: mybridge
4. mydomain/ari/bridges/mybridge/addChannel?api_key=user:pass (POST)
channel: canal1, canal2
and finally:
mydomain/ari/channels/canal1/dial?api_key=user:pass (POST)
caller :canal2

I am sure that I am doing any thing wrong.

What is the result? ext2 receives the call, but when I pick up the phone, ext1 is not receiving the ring tone. If I use the REST to get the info of the channels I get:

[
{
“id”: “canal2”,
“name”: “PJSIP/ext1-00000066”,
“state”: “Down”,
“caller”: {
“name”: “name1”,
“number”: “ext1”
},
“connected”: {
“name”: “”,
“number”: “”
},
“accountcode”: “”,
“dialplan”: {
“context”: “from-internal”,
“exten”: “s”,
“priority”: 1
},
“creationtime”: “2019-03-12T13:21:41.283+0100”,
“language”: “es”
},
{
“id”: “canal1”,
“name”: “PJSIP/ext2-00000067”,
“state”: “Up”,
“caller”: {
“name”: “name2”,
“number”: “ext2”
},
“connected”: {
“name”: “”,
“number”: “”
},
“accountcode”: “”,
“dialplan”: {
“context”: “from-internal”,
“exten”: “s”,
“priority”: 1
},
“creationtime”: “2019-03-12T13:21:50.431+0100”,
“language”: “es”
}
]
Only canal1 is Up.

Does anyone know that I can be doing wrong?

Thanks in advance.


#2

extension: string - The extension to dial after the endpoint answers. Mutually exclusive with ‘app’.

What is wrong with the Originate dialplan application?

You are trying to connect two devices; no Asterisk extensions are involved at all. Your not understanding that is probably the reason for the first mistake.

Please note, I have not used ARI, so I don’t know the correct way of emulating Originate, and can only pick up the more obvious problems.

If you are new to Asterisk, get familiar with doing things in the dialplan before using ARI, AGI, AMI, etc.


#3

Looking at the Asterisk 16 API, it looks like you need /channels/originate, either with a dialplan extension that does the B side Dial, or with Dial as the application and the technology and device as the parameter.

However, that sets up a call completely outside ARI, so one would still have to ask why ARI is not over engineering.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+Channels+REST+API#Asterisk16ChannelsRESTAPI-originate


#4

Ok, thanks. I will review the steps.