This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UCCS API email filtering granularity

I'm wondering if anyone has had any exepreience with the REST API and filetering emails by the hour?

For example:

The following Query returns the entire days worth of email even though I'm looking for only the last hours worth...

var messages = await m_client.
For(x.EmailMessages).
WithinLast(1, RelativeDate.Hour).
Where(x.Direction == 2). //inbound, 3 is outbound
Select(x.Key, x.Sender.EmailAddress.DisplayName, x.Sender.EmailAddress.Name, x.SendDate, x.Subject, x.Recipients.EmailAddress.Name, x.Recipients.EmailAddress.Person.Department, x.Direction).
QueryAllAsync();

I have also tried using between with DateTimes that are hour lone with the same results...  and help or suggestions are appreciated.

Top Replies

  • Hello ,

    I will investigate this and get back to you. 

    Thank you,
    Dave

    Quest Support

  • Hello

    UCA supports two types of queries, aggregate queries and object queries.

    Your query is calling a object query and "selecting" additional fields.
    Unfortunately, object queries accept "date" only.
    In other words, the time portion of the date is ignored.

    On the other hand, Aggregate queries support the time portion of the date.

    For additional details please see the section"About the Time clause" in the UC Analytics Resource Kit.pdf or found online below:

    support.quest.com/.../6


    Thank you,

    Dave

  • Thanks David, yes I saw that in the document as well.  Now I know, so what I can do is allow my client application that queries for a given day to further filter on the time portion.  Appreciate the direction on this!

    Jamie

  • I have more on this

    You could try to add a second 'where' clause against the Message Date

    (i.e. x.MessageDate) where >= $dateValue.

    $dateValue would be a Powershell date that is computed using Get-Date and then AddHours(-1)

    The WithinLast part selects the shard and this additional filter should limit the messages in that shard.

    Please let me know if you have any additional questions.

  • That's the trick.  Works perfectly... thanks so much.

    For reference here is my code (in C#)

    var messages = await m_client.
    For(x.EmailMessages).
    Between(DateTime.UtcNow, DateTime.UtcNow).
    Where(x.Direction == 2). //Direction: 1 is internal, 2 is inbound, 3 is outbound
    Where(x.SendDate > DateTime.UtcNow.AddHours(-1)).
    Select(x.Key, x.Sender.EmailAddress.DisplayName, x.Sender.EmailAddress.Name, x.SendDate, x.Subject, x.Recipients.EmailAddress.Name, x.Recipients.EmailAddress.Person.Department, x.Direction).
    QueryAllAsync();