text stringlengths 0 152 |
|---|
"id": "1548643423.2", |
"name": "PJSIP/SOFTPHONE_A-00000002", |
"state": "Ring", |
"caller": { |
"name": "101", |
"number": "SOFTPHONE_A" |
}, |
"connected": { |
"name": "", |
"number": "" |
}, |
"accountcode": "", |
"dialplan": { |
"context": "sets", |
"exten": "242", |
"priority": 2 |
}, |
"creationtime": "2019-01-27T21:43:43.709-0500", |
"language": "en" |
}, |
"asterisk_id": "08:00:27:27:bf:0e", |
"application": "zarniwoop" |
} |
> |
OK, now we’re going to open yet another shell session3 so we can interact with this |
connection we’ve created. From this new shell, issue the following command: |
$ curl -v -u asterisk:whateveryoudodontusethispassword -X POST \ |
"http://localhost:8088/ari/channels/1548643423.2/play?media=sound:believe-its-free" sd |
Note the "id" from the JSON returned on the wscat session must be used following |
the 'channels/' portion of the curl command. In other words, you must match the |
channel identifier in your command to the channel identifier associated with your |
call. In this manner, you can of course wrangle many calls simultaneously. |
Working with Your ARI Environment Using Swagger |
Asterisk’s ARI has been developed to be compatible with the OpenAPI Specification |
(aka Swagger), which means that many tools compatible with this spec will work with |
ARI. As an example, you can interact with your ARI installation using Swagger-UI, |
which will be useful both for debugging and as a documentation source. |
3 If your computer has only one screen, now is probably the point where you’re thinking what a good idea it |
would be to have more of them. |
334 |
| |
Chapter 19: Asterisk REST Interface |
First up, we’ll need to expose our Asterisk HTTP server to the local network (cur‐ |
rently it’s only allowing connections from 127.0.0.1). In your /etc/asterisk/http.conf file |
you’ll bind the HTTP server to the local IP address of your Asterisk machine: |
$ sudo vim /etc/asterisk/http.conf |
; Enable the built-in HTTP server, and only listen for connections on localhost. |
[general] |
enabled = yes |
;bindaddr = 127.0.0.1 ; comment this out |
bindaddr = 172.29.1.57 ; LAN IP OF YOUR ASTERISK SERVER |
Next, we’ll need to add a line to your /etc/asterisk/ari.conf file: |
$ sudo vim /etc/asterisk/ari.conf |
[general] |
enabled = yes |
pretty = yes |
allowed_origins=http://ari.asterisk.org |
... |
Save and reload the http and ari modules in Asterisk: |
$ sudo asterisk -rx 'module reload http' ; sudo asterisk -rx 'module reload ari' |
Now, from your development desktop, open up your browser and navigate to http:// |
ari.asterisk.org. |
You’ll see a web page similar to Figure 19-1. |
Figure 19-1. Swagger UI for ARI |
Replace localhost with the LAN IP address of your Asterisk server, and in the |
api_key field, put your ARI user:password from /etc/asterisk/ari.conf (for example, |
asterisk:whateveryoudodontusethispassword). If you’ve got all the configuration |
correct, you will be rewarded with the results in Figure 19-2. |
ARI Quick Start |
| |
335 |
Figure 19-2. ARI Swagger |
You are looking at comprehensive documentation for your ARI module, and you can |
actually pass queries to it as well. This is a massively useful debugging aid, and kudos |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.