Skip to main content

Here's one of our developers with a question on how to retrieve accountId and extensionId from your RingCentral account.



"Parameter accountId is required in most of the API resources, may I know what is the account Id in sandbox account? Or where is it found?"


--------------------------------------------------------------------------------------------------------------------------------

The RingCentral service allows its customers to create and register an account that is usually associated with the customer's company. After registering the account with the company main number the user can create extensions of different types and functionality. The extensions can further be assigned with the phone numbers and phone devices.

All the account related link could be looked up in the "Exploring Account and Extension settings" section of our Developers guide here

https://developer.ringcentral.com/api-docs/latest/index.html#!#ExploringAccount.html

In most cases API users do not need to know account ID and extension ID, because API supports simplified syntax if one needs just to refer to the account/extension of logged in user. Tilda "~" character can be used instead these IDs like in the example below:

GET https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~/messsage-store 
More details can be found here: http://developer.ringcentral.com/api-docs/latest/index.html#!#Resources.html
Quick question, I have written an interface for a company I am working with that uses the C# SDK to connect to the APIs.  The code I've written depends on having the account ids to cycle through each user's call log, messages and attachments.  Is there a way to get the account id's for each user that I need to do this for so that I can cycle through the accounts and collect the information we need?  I tried going to the Online Portal for the RC app I have moved to production and attempted to download a user list in excel format and attempted to use the Mailbox IDs to iterate through the users I need to grab info for but this did not work.  Is there a way to get the internal RC account identifiers for users in a list format?
You can retrieve all the user's ( extensions ) within the account using the :

Get Extensions ( API Endpoint ) 

This API returns the list of extensions created for a particular account. All types of extensions are included in this list. Every extension is associated with a parameter named id, for more information you can take a look at the sample request and response here:
https://developer.ringcentral.com/api-docs/latest/index.html#!#RefExtensionList.html



"Account" in RingCentral typically means a company, "Extension" typically means an user. If your app processes data for one company at a time, there is no need to know the account id at all, because there is only one single account and you are implicitly using it already.  To list all of the users, you just to list all of the extensions: https://developer.ringcentral.com/api-docs/latest/index.html?_ga=2.13227319.1817969349.1506220194-10...

Please clarify your situation and your question if you need further help.
Thanks for the help guys.  Your assistance as usual, has been invaluable.  I was successfully able to iterate through all the extensions per both of your instructions and have been able to hit the required endpoints that I needed to hit.  I'm running into a new situation now and wanted to see if either of you could leave me some ideas of what I may be doing wrong.

Here is what my error log is indicating:
2017-09-27 14:06:47,478 [10] ERROR PRIS.RingCentral.MessagesService - Message:
Request rate exceededSource:
RingCentralMethod Causing Error:
Void .ctor(System.Net.Http.HttpResponseMessage, System.Net.Http.HttpRequestMessage)Stack Trace:
   at RingCentral.Http.ApiResponse..ctor(HttpResponseMessage response, HttpRequestMessage request)
   at RingCentral.Platform.Send(HttpMethod httpMethod, Request request)
   at RingCentral.Platform.Get(Request request)
   at PRIS.RingCentral.MessagesService.GetAttachmentContent(ParamsForContentDownloads downloadParams, String& result) in c:ProjectsDotNetPRIS-FrameworkPRIS-FrameworkPRIS.RingCentralServicesMessagesService.cs:line 106


Here is where I make the call in MessagesService.cs:line 106
var txtToBytes = Encoding.UTF8.GetBytes(string.Format("{0}:{1}", Settings.AppKey, Settings.AppSecret));
string encodedText = Convert.ToBase64String(txtToBytes);

// Create request with proper authorization.
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, downloadParams.Attachment.Uri);
request.Headers.TryAddWithoutValidation("Content-Type", @"application/x-www-form-urlencoded;charset=UTF-8");
request.Headers.Add("Authorization", string.Format("Basic {0}", encodedText));

// Handle response
var response = Client.RcPlatform.Get(new Request(request.RequestUri.AbsolutePath));

// Get extension type
result = ExtensionHelpers.GetDefaultExt(response.Headers.ContentType.MediaType);

// Get the binary
return Encoding.ASCII.GetBytes(response.Body);

What is strange is that I get a file with varying sizes in kb, but there is not content.  For example when I open a pdf, it's blank or if I attempt to open a sound file, it doesn't play anything.  Am I handling this correctly?
"Request rate exceeded" means you need to slow down your app. You will encounter this error if you  call the API too fast.

It seems that you are not using the recommended C# Client to access the platform API. Please take a look at the official way to download binary: https://github.com/ringcentral/ringcentral-csharp-client/blob/master/RingCentral.Test/BinaryTest.cs

To retrieve the currently authorizing user's accountId, make an API call to the /restapi/v1.0/account/~ API endpoint which will return the object for the user's account. The accountId will be located in the response id property value.

How can I retrieve my extensionId (Where could I lookup my Extension ID)?

To retrieve the currently authorizing user's extensionId, make an API call to the /restapi/v1.0/account/~/extension/~ API endpoint which will return the object for the user's extension. The extensionId will be located in the response id property value. This will indirectly return the user's accountId in the user's canonical URI which is in the response uri property value.

Miami Video Production Company

,

Amazing


Reply