News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
c# api call logs
Tags: getting started
Sep 24, 2018 at 11:25am   •   3 replies  •  0 likes
david-southern

I have the following console application that I'm using to test the SDK to see if we can get back the call records for our company.


static void Main(string[] args)

{


var Task = DoStuff();

Task.Wait();

}


static public async Task<Boolean> DoStuff() {



RingCentral.RestClient rc = new RingCentral.RestClient("fakekey", "fakesecret", true);


await rc.Authorize("16159059217", "100104", "fakepassword");


var calllogs = await rc.Restapi().Account("~").Extension("100104").CallLog().List();


return true;

}



However, when the code get's the the line beginning 'var calllogs', I get the error below:


System.AggregateException

HResult=0x80131500

Message=One or more errors occurred.

Source=mscorlib

StackTrace:

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)

at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)

at System.Threading.Tasks.Task.Wait()

at ConsoleApp1.Program.Main(String[] args) in C:\_work\RingCentral\SDK Test\ConsoleApp1\Program.cs:line 15


Inner Exception 1:

FlurlHttpException: Call failed with status code 404 (Not Found): GET https://platform.ringcentral.com/restapi/v1.0/account/~/extension/100104/call-log


Not sure what I'm doing wrong. I'm trying to follow the documentation associated with the c# sdk on github.


3 Answers
answered on Sep 25, 2018 at 6:14am  
So what I eventually had to do to get all the records for our organization is the following:

rc.Restapi().Account("~").CallLog().List();

In other words, I just removed the call to Extension.

the full code looks like this:

      static public async Task<Boolean> ExtractRecords() {

            RingCentral.ExtensionCallLogResponse response;
            List<RingCentral.CallLogRecord> theList = new List<RingCentral.CallLogRecord>();

            int pageNum = 0;

            RingCentral.RestClient rc = new RingCentral.RestClient("fakekey", "fakesecret", true);

            await rc.Authorize("16159059217", "100104", "fakepwd");

            do
            {
                pageNum++;
                response = await rc.Restapi().Account("~").CallLog().List(new { dateFrom = "2018-08-17", dateTo = "2018-08-22", page = pageNum.ToString(), perPage = 1000 });
                theList.AddRange(response.records);
                System.Threading.Thread.Sleep(7000); 
            } while (response.navigation.nextPage != null);

            return true;
        }

'course I'm going to have to parameterize dates and such, but for now this gets the data extracted.

 0
answered on Sep 24, 2018 at 11:58am  
Thanks Phong!  I did not know that about the extension number and id being different.  That gets me passed that error.

but now, even though I'm passed the error, I'm not getting any call logs back.  Do I need to supply an extension id that has admin priviledges vs. just supplying a '~'?



 0
answered on Sep 24, 2018 at 11:39am  
Hi David,

Please note that the extension number and extension Id are different!

What you use above was the extension number and that will not work.

You don't need to specify the extension id but just use the tilde ~ sign to read call log of that extension. If the logged in extension is an Admin, then you will be able to read call logs of all extensions under that account. Otherwise, it will read only the call log on that particular extension.

+ Phong

 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us