Home > Mobile >  Twilio C# api usage records always show 0
Twilio C# api usage records always show 0

Time:09-19

I need to show daily sms sent count using Twilio C# api. I am referring to: https://www.twilio.com/docs/usage/api/usage-record Here is my code:

 public int sentToday()
    {

        int sTotalTodaysRecord = 0;
        string AccountId = ConfigurationManager.AppSettings["AccountId"];
        string AuthToken = ConfigurationManager.AppSettings["AuthToken"];

       

        TwilioClient.Init(AccountId, AuthToken);
        //var records = TodayResource.Read();

        var records = LastMonthResource.Read();
        foreach (var record in records)
        {
            sTotalTodaysRecord = record.Count;
            break;
        }
        return sTotalTodaysRecord;
    }

whether I use TodayResource or LastMonthResource count is always 0. I can check the sms logs and I know messages have been sent last month or even on particular day. What am I missing here ? Or do I have to count it from sms logs ?

CodePudding user response:

Is the problem that you assign where you should add?

sTotalTodaysRecord = record.Count;

->

sTotalTodaysRecord = record.Count;

  • Related