Skip to main content

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:_workRingCentralSDK TestConsoleApp1Program.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.


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
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 '~'?



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.

Reply