Query Event History

For an Access Granted Event

This example will find one event that matches the Access Granted that we are looking for and out put all of the specific data about the event that we might be interested in.

For more information on Events and the methods used please look at EventTypeInfo.

Example in C#

var apps = await client.GetAppsAsync(currentInstance); //getting the applications
var mercuryApp = apps.Single(a => a.CommonName == "Mercury Driver Service"); //get the mercury app
var eventTypes = await client.GetEventTypesAsync(mercuryApp); //grabbing event types
var accessGranted = eventTypes.Single(x => x.CommonName == "Access Granted"); 

var events = await client.GetEventsAsync(currentInstance, forKeys: new[] { accessGranted.Key });

var e = events.FirstOrDefault(); //only want a single event
var bytes = Convert.FromBase64String(e.EventDataBsonBase64);
var eventData = bytes.FromBson<ExpandoObject>();

// OR
// var eventData = e.EventDataBsonBase64.ToBsonDocumentFromBase64();

foreach (var kv in eventData)
{
	Console.WriteLine($"{kv.Key} - {kv.Value}");
}

Example in CURL

# The following call will need to be iterated through.
curl -X GET 
    \ 'https://keepapi.feenicshosting/api/f/INSTANCE.KEY/events?page=0&pageSize=1000&includeSubFolders=False&includeSharedInstances=False&spanScope=False&requiresAck=False&priorityThreshold=0&forKeys=MERCURY_ACCESS_GRANTED_EVENTTYPE.KEY' 
    \  -H 'Authorization: Bearer TOKEN_GOES_HERE'