c# api call logs

  • 1
  • Problem
  • Updated 2 months ago
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.  

Photo of David Southern

David Southern

  • 260 Points 250 badge 2x thumb

Posted 3 months ago

  • 1
Photo of Phong Vu

Phong Vu, Devangelist

  • 3,192 Points 3k badge 2x thumb
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
Photo of David Southern

David Southern

  • 260 Points 250 badge 2x thumb
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 '~'?


Photo of Phong Vu

Phong Vu, Devangelist

  • 3,082 Points 3k badge 2x thumb
Hi David,

Can you show the query parameters? You must set the dateFrom and dateTo (with a correct format). Otherwise it will just read the call log of that extension for the past 1 day and you might not have any call log for that short period of time.

Please check and let me know.

+ Phong
Photo of David Southern

David Southern

  • 260 Points 250 badge 2x thumb
I haven't tried putting in a date yet.  Our goal is to pull all the call records for our organization and just make sure that is working.  Later on (when we actually go into production) we'll pull all the records for a day at a time.  

Am I using the wrong method call?
Photo of Phong Vu

Phong Vu, Devangelist

  • 3,082 Points 3k badge 2x thumb
So you just have to put some date for the fromDate. The default is just the past 24 hrs. When you want to read all/everything you must specified the dateFrom as far as your account was created.
Photo of David Southern

David Southern

  • 260 Points 250 badge 2x thumb
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.