question

david-southern11373 avatar image
david-southern11373 asked david-southern11373 answered

c# api call logs

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.


getting started
1 |3000

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

Phong Vu avatar image
Phong Vu answered
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
1 |3000

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

david-southern11373 avatar image
david-southern11373 answered Phong Vu commented
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 '~'?


3 comments
1 |3000

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

Phong Vu avatar image Phong Vu ♦♦ commented ·
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
0 Likes 0 ·
david-southern11373 avatar image david-southern11373 commented ·
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?

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ commented ·
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.
0 Likes 0 ·
david-southern11373 avatar image
david-southern11373 answered
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.
1 |3000

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

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys