question

keith-stephens7892 avatar image
keith-stephens7892 asked Phong Vu answered

C# get call logs

I have a sanbox set up, and I have 2 call logs in it both are missed calls, but I don't think that matters in my case.


What I want to do is return all call logs for all users to display a count of how many Inbound and outbound calls were made by each user.


The code I have in my web page seems to execute fine, but it is not returning any call logs.

[HttpGet]

[Route("api/CallLogs/")]

public async Task<string> GetCallLogs()

{


rc = new RestClient(appKey, appSecret, isProduction);

await rc.Authorize(userName, "", password);

DateTime input = DateTime.Today;

int delta = DayOfWeek.Monday - input.DayOfWeek;

DateTime monday = input.AddDays(delta);


var extension2 = rc.Restapi().Account().Extension();

var callLogs = await extension2.CallLog().List(new { dateFrom = monday.ToString("yyyy-MM-dd") });

//var callLogs = await extension2.CallLog().List(new { direction = "Inbound" });

//var callLogsO = await extension2.CallLog().List(new { direction = "Outbound" });

return callLogs.records.Count().ToString();

}


The count comes back as 0.

But when I go to RC page https://developer.ringcentral.com/api-explorer/latest/index.html#/!/Call_Log/loadCompanyCallLog


And run Get company call logs I get back both of my calls.

Thanks for any help or advice.

Keith.


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.

1 Answer

Phong Vu avatar image
Phong Vu answered
Hi Keith,

If you want to read call logs from all users, login with the main company account (or extension with admin role). Then call the calllog endpoint at the account level.

var mainAccount = rc.Restapi().Account();
var callLogs = await mainAccount.CallLog().List(new { dateFrom = monday.ToString("yyyy-MM-dd");
...

Let me know if this helps.
+ 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.

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