need extensionNumber returned in active-calls

  • 2
  • Problem
  • Updated 2 years ago
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? 
Photo of Point of Rental Software

Posted 2 years ago

  • 2
Photo of Benjamin Dean

Benjamin Dean, Alum

  • 8,642 Points 5k badge 2x thumb
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.
Property was not there. it's supposed to be ExtensionNumber
response like this:
"uri" : "https://platform.ringcentral.com/restapi/v1.0/account/502681018/active-calls?page=1&perPage=100&...;,  "records" : [ {
    "uri" : "https://platform.ringcentral.com/restapi/v1.0/account/502681018/extension/502681018/call-log/ZxQNRgD...;,
    "id" : "ZxQNRgDkqtiDZvc",
    "sessionId" : "1246140516019",
    "startTime" : "2016-12-06T20:00:55.000Z",
    "duration" : 71,
    "type" : "Voice",
    "direction" : "Inbound",
    "action" : "Phone Call",
    "result" : "Voicemail",
    "to" : {
      "phoneNumber" : "+18177696339",
      "name" : "Point of Rental Software Main",
      "location" : "Fort Worth, TX"
    },
    "from" : {
      "phoneNumber" : "+12145641477",
      "name" : "ORMESHER JONATH",
      "location" : "Grand Prairie (Dallas), TX"
    }
  }
Photo of Tyler Long

Tyler Long, Official Rep

  • 6,614 Points 5k badge 2x thumb
According to https://developer.ringcentral.com/api-docs/latest/index.html#!#CallLogCallerInfo

There should be a property named "extensionNumber". So this is probably a bug from server side.
Photo of Victor Shisterov

Victor Shisterov

  • 60 Points
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"
    }
  }
}
(Edited)
if I put extension to login request, it didn't allow me to log in.  how can I get active call record because I can't log in?
Dim Username As String = "phoneNumber"
     Dim Password As String = "myPassword"
        'Dim Extension As String = "MyExtension"
the Main goal is I want to get whom I am speaking with. I log in with main Company Number and password, I can get all active calls. I need to which extension is answering the call 
Photo of Tyler Long

Tyler Long, Official Rep

  • 5,584 Points 5k badge 2x thumb
Could you please post the error message for "can't login" ? I wan to know the reason for failing to login.

Thanks
(Edited)
so I am confused :
1. I log in with Main company# with my extension #
UserName = MainCompany Phone#,
Password = My  password to log in RingCentral App. ( I have my own direct phone # and extension Number)
extension = My extension Number 
this works . so I can get Active Call : https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~/active-calls?view=Detailed&page=1&perpage=1000.
2. I log in with Main company# + password for main company and NO extension.
this means I can get all Active-calls for all extension.
but I want to get record for one user. such as:
https://platform.ringcentral.com/restapi/v1.0/account/~/extension/7020/active-calls?view=Detailed&p...;

7020 is user extension Number in https://service.ringcentral.com/users/index.html#/users.  
I get error: 404 Not found  

"errorCode": "CMN-102","message": "Resource for parameter [extensionId] is not found",
"errors": [  {
"errorCode": "CMN-102",
"message": "Resource for parameter [extensionId] is not found",
"parameterName": "extensionId"
}


],

"parameterName": "extensionId"

I have around 60 different users which is in the user list from https://service.ringcentral.com/users/index.html#/users.  is ExtensionID in request and user Extension Number different? then how can I get record for one extension Number?
Photo of Tyler Long

Tyler Long, Official Rep

  • 5,584 Points 5k badge 2x thumb
I know the root cause.
https://platform.ringcentral.com/restapi/v1.0/account/~/extension/7020/active-calls?view=Detailed&p...;

7020 is NOT extension ID, it's extension number. Extension ID is expected.

You can get a list of the extensions with their IDs and Numbers with GET  https://platform.ringcentral.com/restapi/v1.0/account/~/extension

Once you get the list, you can create a mapping from ExtensionNumber to ExtensionID. 

For any ExtensionNumber, you check the mapping for its ExtensionID before calling further APIs.
(Edited)
Photo of VB

VB, Official Rep

  • 1,470 Points 1k badge 2x thumb
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

 
Photo of Tyler Long

Tyler Long, Official Rep

  • 6,716 Points 5k badge 2x thumb
https://developer.ringcentral.com/api-docs/latest/index.html#!#RefGetDetailedExtensionPresenceEvent

Scroll down to the bottom and find "Detailed Extension Presence Event".
it's NOT what I want,  the response I got is the follow structure, it's totally different from your Document.

{
  "uri" : "https://platform.ringcentral.com/restapi/v1.0/account/XXXXXX/presence?page=1&perPage=100";,
  "records" : [ {
    "uri" : "https://platform.ringcentral.com/restapi/v1.0/account/502681018/extension/502886018/presence";,
    "extension" : {
      "uri" : "https://platform.ringcentral.com/restapi/v1.0/account/502681018/extension/502886018";,
      "id" : xxxxxx,
      "extensionNumber" : "605"
    },
    "presenceStatus" : "Offline"
  },
 
 {
    "uri" : "https://platform.ringcentral.com/restapi/v1.0/account/502681018/extension/1260150019/presence";,
    "extension" : {
      "uri" : "https://platform.ringcentral.com/restapi/v1.0/account/502681018/extension/1260150019";,
      "id" : 1260150019,
      "extensionNumber" : "6011"
    },
    "presenceStatus" : "Available",
    "telephonyStatus" : "NoCall",
    "userStatus" : "Available",
    "dndStatus" : "TakeAllCalls",
    "allowSeeMyPresence" : true,
    "ringOnMonitoredCall" : false,
    "pickUpCallsOnHold" : false
  },
 
   {
    "uri" : "https://platform.ringcentral.com/restapi/v1.0/account/502681018/extension/1189100019/presence";,
    "extension" : {
      "uri" : "https://platform.ringcentral.com/restapi/v1.0/account/502681018/extension/1189100019";,
      "id" : 1189100019,
      "extensionNumber" : "3031"
    },
    "presenceStatus" : "Busy",
    "telephonyStatus" : "CallConnected",
    "userStatus" : "Available",
    "dndStatus" : "TakeAllCalls",
    "allowSeeMyPresence" : true,
    "ringOnMonitoredCall" : false,
    "pickUpCallsOnHold" : false,
    "activeCalls" : [ {
      "id" : "90437c898821467c88f7b5211447e361",
      "direction" : "Outbound",
      "from" : "+18179009177",
      "to" : "3193380886",
      "telephonyStatus" : "CallConnected",
      "sessionId" : "1284674918019"
    }, {
      "id" : "642c13f8030a46c2a43a2389444afac0",
      "direction" : "Inbound",
      "from" : "+13193380886",
      "to" : "+18179009177",
      "telephonyStatus" : "CallConnected",
      "sessionId" : "1284674921019"
    } ]
  },
 
 
 
 
  ],
  "paging" : {
    "page" : 1,
    "totalPages" : 2,
    "perPage" : 100,
    "totalElements" : 112,
    "pageStart" : 0,
    "pageEnd" : 99
  },
  "navigation" : {
    "nextPage" : {
      "uri" : "https://platform.ringcentral.com/restapi/v1.0/account/502681018/presence?page=2&perPage=100";
    },
    "firstPage" : {
      "uri" : "https://platform.ringcentral.com/restapi/v1.0/account/502681018/presence?page=1&perPage=100";
    },
    "lastPage" : {
      "uri" : "https://platform.ringcentral.com/restapi/v1.0/account/502681018/presence?page=2&perPage=100";
    }
  }
}



Photo of Tyler Long

Tyler Long, Official Rep

  • 6,716 Points 5k badge 2x thumb
We are talking about different things. It's Subscription API instead of REST API. You cannot just send an HTTP request and get the information you want. Instead, you create a subscription, and whenever there are events, your app will be notified. It's similar to the listener pattern.

Not sure which programming language you are talking about. Here is sample code for C# (other languages are quite similar): https://github.com/ringcentral/ringcentral-csharp-client#subscription

And here is the documentation for subscription: https://github.com/ringcentral/ringcentral-api-docs/blob/master/docs/notifications.md
thank you.  so I did use rest api. Dim _url As String = "https://platform.ringcentral.com/restapi/v1.0/account/~/presence?detailedTelephonyState=true";   but still get result.

 what I am trying to do is: I want to get all active calls for All extension Numbers.  so I have to use Subscription and Notification? 
Photo of Tyler Long

Tyler Long, Official Rep

  • 6,716 Points 5k badge 2x thumb
It is better to use Subscription. Because subscription can give you real time updates. For the Rest API you need to call it again and again which might hit the Rate Limits: http://ringcentral-api-docs.readthedocs.io/en/latest/rate_limits/