Skip to main content

I am working in Production App, and try to get Active Calls. the field I need is ExtensionNumber from response. but it was empty in response. I login in with company main Number and request is: "https://platform.ringcentral.com/restapi/v1.0/account/~/active-calls?view=Detailed";


I even tried "https://platform.ringcentral.com/restapi/v1.0/account/~/active-calls"; still no luck.



why can't I get extension Number in response?




When you say "empty in response", do you mean the property was not present, or that there is an "extensionId" property present, but the value is empty string/null/undefined?

I do not see an "extensionId" or "extensionNumber" property in the active calls response payload.

You could use Subscriptions to capture this information, or you could use the 'uri' property that is returned in the active-calls response as it contains extensionId-specific URI data.
Hi, extensionNumber is returned for internal calls (within one RingCentral account) only. In that case phoneNumber is not returned:
GET https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~/active-calls

HTTP/1.1 200 OK {   "uri": "https://platform.ringcentral.com/restapi/v1.0/account/1812802010/extension/1812802010/active-calls?page=1&perPage=100",   "records":    [             {          "uri": "https://platform.ringcentral.com/restapi/v1.0/account/1812802010/extension/1812802010/call-log/XwRplsODX095hPs?view=Simple",         "id": "XwRplsODX095hPs",          "sessionId": "1148687901011",          "startTime": "2016-12-07T12:52:43.000Z",          "duration": 26,          "type": "Voice",          "direction": "Outbound",          "action": "VoIP Call",          "result": "Call connected",          "to":          {             "extensionNumber": "532",             "name": "John Smith"          },          "from": {"name": "Victor Shisterov"}       } ],
  "paging" : {
    "page" : 1,
    "perPage" : 100,
    "pageStart" : 0,
    "pageEnd" : 0
  },
  "navigation" : {
    "firstPage" : {
      "uri" : "https://platform.ringcentral.com/restapi/v1.0/account/1812802010/extension/1812802010/active-calls?page=1&perPage=100"
    }
  }
}

I have taken this case offline. However,  there are few things I would like to point out.
1. Active calls API will return empty body when there are no active calls existing for the extension. Active calls will return body only when there are active calls or the calls are ended and will show up in the body for couple of minutes( around 10 min or so)  and then will return the empty body.

2. Also, as Tyler mentioned,  the extensionID is different from the extensionNumber 
Eg:  ExtensionNumber 101 could be tied to extensionID  6493762 in the RC backend. 
To find out all the extensionIDs for the extension numbers,  you could make a get to  /account/~/extension API. You can use the body of the response to create a mapping in the backend.

3. Polling for Active Calls using /active-calls api would be a bad idea if you want to track the incoming/outgoing calls for an account or extensions. 
Setting up a push notification system using Subscription API in the backend server or by using WebHooks and adding event filter for tracking presence status of calls using " /restapi/v1.0/account/~/extension/~/presence?detailedTelephonyState=true  " makes more sense.  While the /presence returns the detailed information of the call,  you could use the sessionID from the presence notification  response body and map it with call-log record  via api call with a seach query as mentioned below: 
/restapi/v1.0/account/~/call-log?sessionId=XXXXXXXX

 

Reply