The Subscribe method allows you to monitor extension for events such as:
...
The method will return as soon as any events occurs on one of the target extensions or when the timeout occurs.
Note:
To guarantee that you don't miss any events between calls to subscribe you use the 'seq' data returned by a call to subscribe as the value of lastSequenceNumber in the next call to subscribe.
...
A single subscribe method will often return multiple events.
Entry point:
...
linenumbers | true |
---|
...
NOTE: you must use the POST method, however you don't need to send any data.
Code Block | ||
---|---|---|
| ||
https://<server host>/servicemanager/rest/CallManagementAPI/subscribe |
HTTP Method: POST
Content Type: application/x-www-form-urlencoded
Parameters (case sensitive):
...
Argument |
---|
...
Description |
---|
...
Mandatory |
---|
exten |
...
a |
...
comma-separated |
...
list |
...
of |
...
extensions |
...
to |
...
monitor |
...
for |
...
calls. |
...
Yes | ||
lastSequenceNumber | The client should retrieve this number from the CallData.seq value in the API response. The first call you make to subscribe should set this value to 0. Subsequent MUST use the lastSequenceNumber returned in the CallData.seq. NOTE: If you to pass back the lastSequenceNumber obtained from the CallData.seq then you will either receive duplicate events or you will miss events. | Yes |
timeOut | the poll timeout in seconds - default is 10 if this parameter is omitted. | No |
apiKey | api key provided by Noojee Support | Yes |
...
Code Block |
---|
curl -X POST "https://<some hostname>/servicemanager/rest/CallManagementAPI/subscribe?timeOut=0&apiKey=XXXX-XXXXX-XXXXX-XXXXX&lastSequenceNumber=0&instanceId=1&exten=400,410,410" |
Examples:
Code Block | ||
---|---|---|
| ||
https://127.0.0.1:8080<server hostname>/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60& apiKey=f863246a-973e-11e6-8784-08002718f5b5&lastSequenceNumber=28&instanceId=1&exten=400,410,410 |
...
Code Block | ||
---|---|---|
| ||
httphttps://127.0.0.1:8080<server hostname>/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60 &apiKey=f863246a-973e-11e6-8784-08002718f5b5&lastSequenceNumber=32&instanceId=1&exten=400,410,410 |
...
Code Block | ||
---|---|---|
| ||
http://127.0.0.1:8080<server hostname>/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60& apiKey=f863246a-973e-11e6-8784-08002718f5b5&lastSequenceNumber=36&instanceId=1&exten=400,410,410 |
...
To answer the first call listed in the sample above use the uniqueCallId and pass it in as the uniqueId to the answer method:
Code Block | ||
---|---|---|
| ||
answer?answerString=...&apiKey=....&exten=101&uniqueId=1403148776.566 |
...
Code Block | ||
---|---|---|
| ||
httphttps://127.0.0.1:8080<server hostname>/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60& apiKey=f863246a-973e-11e6-8784-08002718f5b5&lastSequenceNumber=0&instanceId=1&exten=400,410,410 {"Data":{ |
Code Block | ||
---|---|---|
| ||
"410": [{"CallData":{ "canAnswer":true, "callerId":"400", "uniqueCallId":"1412749510.488", "callStartTime":"", "isQueueCall":false, "isClickToDialCall":false, "inbound":true, "status":"Ringing"},"CallID":2,"Code":0}], "400": [{"CallData":{ "canAnswer":false, "callerId":"", "uniqueCallId":"1412749517.489", "callStartTime":"", "isQueueCall":false, "isClickToDialCall":false, "inbound":false, "status":"Dialing Out"} ,"CallID":1,"Code":0}]},"seq":4,"Code":0} |
...
Code Block | ||
---|---|---|
| ||
httphttps://127.0.0.1:8080<server hostname>/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60& apiKey=f863246a-973e-11e6-8784-08002718f5b5lastSequenceNumber=4&instanceId=1&exten=400,410,410 |
...
Code Block | ||
---|---|---|
| ||
httphttps://127.0.0.1:8080<server hostname>/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60& apiKey=f863246a-973e-11e6-8784-08002718f5b5&lastSequenceNumber=6&instanceId=1&exten=400,410,410 |
...
Code Block | ||
---|---|---|
| ||
{"Data":{ "410": [{"CallData":{ "canAnswer":false, "callerId":"400", "uniqueCallId":"1412749510.488", "callStartTime":"2014/10/08 17:25:18", "isQueueCall":false, "isClickToDialCall":false, "inbound":true, "status":"Hungup"},"CallID":2,"Code":0}], "400": [{"CallData":{ "canAnswer":false, "callerId":"410", "uniqueCallId":"1412749517.489", "callStartTime":"2014/10/08 17:25:18", "isQueueCall":false, "isClickToDialCall":false, "inbound":false, "status":"Hungup"},"CallID":1,"Code":0}]},"seq":10,"Code":0} |
Call 2: Extension 400 dials extension 410, 410 is busy.
Code Block | ||
---|---|---|
| ||
httphttps://127.0.0.1:8080<server hostname>/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60& apiKey=f863246a-973e-11e6-8784-08002718f5b5&lastSequenceNumber=10&instanceId=1&exten=400,410,410 |
...
Code Block | ||
---|---|---|
| ||
httphttps://127.0.0.1:8080<server hostname>/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60& apiKey=f863246a-973e-11e6-8784-08002718f5b5&lastSequenceNumber=14&instanceId=1&exten=400,410,410 |
...