2

I’m looking at using the .NET SDK, and I am trying a test query. I am having trouble creating a QueryTimeframe for say the last 30 minutes. How do I do that?

Kyle Wild
  • 8,845
  • 2
  • 36
  • 36

1 Answers1

3

Try the QueryRelativeTimeframe class, like:

static void Main(string[] args)
{
    var keenClient = new KeenClient(new ProjectSettingsProviderEnv());

    // create an event to query
    //keenClient.AddEvent("ACollection", new { AProperty = "AValue" });

    // query the event
    var result = keenClient.QueryExtractResource("ACollection", QueryRelativeTimeframe.PreviousNMinutes(30)).ToList();
    if (result.Any())
        Console.WriteLine(result.First());
    else
        Console.WriteLine("No matching records");
    Console.ReadKey();
}

However, there was a small bug in PreviousNMinutes relative timeframe query, you would have gotten an error back from the server due to a formatting error. I've pushed an update, you can pull it from github or update with Nuget to v0.3.7.

DaveK
  • 709
  • 7
  • 21