Good day all, I'm in the process of trying to retrieve call data from Twilio using their C# SDK. Using the StartTime seems to pull all records for that given date which is not what I want to achieve. Ultimately I want to only pull data within a time range of the given date. I have looked on the internet and have seen mention of using the StartTimeBefore and StartTimeAfter. This does not appear to work either. Any thoughts as to how I can achieve this? Below is some code that I have attempted that does not seem to work.
NOTE: I have also tried some different permutations with EndTimeAfter to put bounds on it that way as well, but again that did not work.
public class RetrieveTwilioCalls
{
private readonly string _accountSid;
private readonly string _authToken;
public RetrieveTwilioCalls(IConfigurationRoot configuration)
{
_accountSid = configuration["TWILIO_ACCOUNT_SID"];
_authToken = configuration["TWILIO_AUTH_TOKEN"];
}
public async Task ExecuteAsync()
{
TwilioClient.Init(_accountSid, _authToken);
var startDateTimeUTC = new DateTime(2022, 2, 8, 15, 15, 00).ToUniversalTime();
var endDateTimeUTC = new DateTime(2022, 2, 8, 16, 18, 01).ToUniversalTime();
var call1 = await CallResource.ReadAsync(new ReadCallOptions { StartTimeBefore = startDateTimeUTC, EndTimeAfter = endDateTimeUTC, PageSize = 100 });
Console.WriteLine(call1.ElementAt(0).To);
}
}