Comments (4)
Nevermind! I was able to figure this out. The code below will pull the first 2500 extensions of the account (sorted by ext #) and output to a text file with Ext: # and ID: # so that a call can be made directly to one extension by using var extension = rc.Restapi().Account().Extension("ID#)
var extensions = rc.Restapi().Account().Extension().List(new { perPage = 2500 }).Result.records;
var count = 0;
string path = @"PATH TO FILE";
while (count < 2500)
{
foreach (var extension in extensions)
{
//Console.WriteLine(count.ToString());
//Console.WriteLine(extension.extensionNumber);
if (count.ToString() == extension.extensionNumber)
{
string field = "Ext: " + extension.extensionNumber + " ID: " + extension.id;
Console.WriteLine(field);
// This text is added only once to the file.
if (!File.Exists(path))
{
// Create a file to write to.
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("Hello");
}
}
// This text is always added, making the file longer over time
// if it is not deleted.
using (StreamWriter sw = File.AppendText(path))
{
sw.WriteLine(field);
}
}
}
count = count + 1;
}`
from ringcentral-csharp-client.
Awesome!
Actually I am not sure whether you are able to fetch as many as 2500 records with one request. Because some of RingCentral's API endpoints only allow 1000 as maximum perPage limit. You will be fine if your account has fewer than 1000 extensions. But if there are 1000+ extensions, you can do pagination like this:
var extensions = rc.Restapi().Account().Extension().List(new { perPage = 1000, page = 2 }).Result.records;
Code above returns page 2 of the results.
from ringcentral-csharp-client.
My company only has ~160 extensions but the actual extension numbers range from 2 to ~2000 so that is why I made the range so wide. I actually also meant to put perPage = 1000 in the code I pasted above, but Copy/Pasted the wrong version of the code. Whoops!!
from ringcentral-csharp-client.
If there are only ~160 extensions, pagination is not needed. As I said you could fetch as many as 1000 records with single request. All seem fine to me now. 👍
from ringcentral-csharp-client.
Related Issues (20)
- Incoming notification HOT 1
- Get caller name using DetailedTelephonyState event filter. HOT 2
- .Net Core Webhosting not able to find the referenced package assemblies Micorsoft.AspNetCore HOT 1
- REST API which should support multi target framework(.net 472 and .net core) HOT 1
- Make header info available? HOT 2
- QUESTION: Subscription: Message Store HOT 2
- How about a complete example in C# HOT 3
- Running in console app HOT 2
- Missing FaxPath.PostParameters HOT 2
- Create subscription after token refreshed HOT 1
- Access Token expires HOT 1
- Add documentation for Auth Code HOT 1
- POST Bulk Assign for Call Queues Pointing to GLIP and not Call Queues Object HOT 7
- Cross platform targeting HOT 1
- Signed/StrongNamed version? HOT 1
- Not able to generate access tokens after Authorization HOT 1
- rc.Authorize hangs up
- Add Support for Call Log Sync - Account level HOT 1
- 3 legged Authorization
- Obsolete reference to Microsoft.AspNet.WebApi.Client
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ringcentral-csharp-client.