question

point-of-rental-software3262 avatar image
point-of-rental-software3262 asked ·

need extensionNumber returned in active-calls

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? 



aaa
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

benjamin-dean avatar image
benjamin-dean answered ·
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.
3 comments Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Property was not there. it's supposed to be ExtensionNumber
0 Likes 0 · ·
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"
    }
  }
0 Likes 0 · ·
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.
0 Likes 0 · ·
victor-shisterov38 avatar image
victor-shisterov38 answered ·
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"
    }
  }
}
7 comments Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

thanks. so still 1 more questions: I log in with main company number.
1. so we can not know who is answering the inbound call from outside customer?  I developed my own app to show call which extensionnumber is answering the  call.

2. when I  https://platform.ringcentral.com/restapi/v1.0/account/~/active-calls, I can get all active records. but if I use 
https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~/active-calls  Nothing returned.  
0 Likes 0 · ·
For #2,  /account/~/extension/~/active-calls only returns records for the currently logged in extension. If the current extension is not answering a call, there will be nothing to return. Not sure if this answers your question.
0 Likes 0 · ·
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"
0 Likes 0 · ·
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 
0 Likes 0 · ·
Could you please post the error message for "can't login" ? I wan to know the reason for failing to login.

Thanks
0 Likes 0 · ·
Show more comments
vb avatar image
vb answered ·
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

 
6 comments Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

thank you for reply, I did get detail information from  / restapi /v1.0/account/~/extension/~/presence?detailedTelephonyState=true .   
I didn't find any schema or structure for response in API document.   I have to create my own structure based on response file. but I don't want to missing any elements.  for instance:
uri,
records(
 uri:
   extension:
        (uri:
         id:
         extensionNumber
        )
   presenceStatus:
   telephonystatus:
   userstatus:
   dndstatus:
   allowseeMyPresence:
   ringOnMonitoredCall:
   PickUpCallsOnHold:
   ActiveCalls
           (
               id:
               direction:
               from:
               to:
               telephonyStatus:
               sessionId:
           )
  Paging: 
         (
        page:
        totalPage:
        perPage:
       totalElements:
       pageStart:
       PageEnd
      )
Navigation
       (
       NextPage (uri:)
       FirstPage (uri)
       LastPage(uri)
     )
);

could you please tell me where I can get correct schema of response, so I can build my Class.  thanks
0 Likes 0 · ·
https://developer.ringcentral.com/api-docs/latest/index.html#!#RefGetDetailedExtensionPresenceEvent

Scroll down to the bottom and find "Detailed Extension Presence Event".
0 Likes 0 · ·
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";
    }
  }
}



0 Likes 0 · ·
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


0 Likes 0 · ·
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? 
0 Likes 0 · ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.