Exchange Server TechCenter > Exchange Server Forums > Development > Bug in EWS Managed API: GetUserAvailability - SOAP call does not include time component of TimeWindow
Ask a questionAsk a question
 

Proposed AnswerBug in EWS Managed API: GetUserAvailability - SOAP call does not include time component of TimeWindow

  • Thursday, November 05, 2009 11:58 AMGraham King Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    When using the GetUserAvailability method on the ExchangeService object the Time component of the StartDate and EndDate properties of the TimeWindow parameter do not get included in the soap call that results.

    The below code is trying to find user availability between 0900 and 1400 on 01/12/2009 for two users. Lines in bold.

    ExchangeService service = CreateServiceReferences();
    AttendeeInfo[] attendees = new AttendeeInfo[] { "user1@example.com", "user2@example.com" };
    DateTime startDate = new DateTime(2009, 12, 1, 9, 0, 0);
    DateTime endDate = new DateTime(2009, 12, 2, 14, 0, 0);
    TimeWindow timeWindow = new TimeWindow(startDate, endDate);
    
    service.TraceEnabled = true;
    service.TraceFlags = TraceFlags.All;
    
    GetUserAvailabilityResults results = service.GetUserAvailability(attendees, timeWindow, AvailabilityData.FreeBusy);

    The trace output is below.  You will notice that the time component of the Time Window is set to 00:00:00.  This results in an exception because StartDate and EndDate are the same date AND time, when the time should be different.  Lines in bold.

    <EwsLogEntry EntryKind="EwsRequest" ThreadId="10" Timestamp="05/11/2009 11:52:03">
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Header>
          <t:RequestServerVersion Version="Exchange2007_SP1" />
          <t:TimeZoneContext>
            <t:TimeZoneDefinition Id="GMT Standard Time" />
          </t:TimeZoneContext>
        </soap:Header>
        <soap:Body>
          <m:GetUserAvailabilityRequest>
            <t:TimeZone>
              <t:Bias>0</t:Bias>
              <t:StandardTime>
                <t:Bias>0</t:Bias>
                <t:Time>02:00:00</t:Time>
                <t:DayOrder>5</t:DayOrder>
                <t:Month>10</t:Month>
                <t:DayOfWeek>Sunday</t:DayOfWeek>
              </t:StandardTime>
              <t:DaylightTime>
                <t:Bias>-60</t:Bias>
                <t:Time>01:00:00</t:Time>
                <t:DayOrder>5</t:DayOrder>
                <t:Month>3</t:Month>
                <t:DayOfWeek>Sunday</t:DayOfWeek>
              </t:DaylightTime>
            </t:TimeZone>
            <m:MailboxDataArray>
              <t:MailboxData>
                <t:Email>
                  <t:Address>user1@example.com</t:Address>
                </t:Email>
                <t:AttendeeType>Required</t:AttendeeType>
                <t:ExcludeConflicts>false</t:ExcludeConflicts>
              </t:MailboxData>
              <t:MailboxData>
                <t:Email>
                  <t:Address>user2@example.com</t:Address>
                </t:Email>
                <t:AttendeeType>Required</t:AttendeeType>
                <t:ExcludeConflicts>false</t:ExcludeConflicts>
              </t:MailboxData>
            </m:MailboxDataArray>
            <t:FreeBusyViewOptions>
              <t:TimeWindow>
                <t:StartTime>2009-12-01T00:00:00</t:StartTime>
                <t:EndTime>2009-12-01T00:00:00</t:EndTime>
              </t:TimeWindow>
              <t:MergedFreeBusyIntervalInMinutes>30</t:MergedFreeBusyIntervalInMinutes>
              <t:RequestedView>Detailed</t:RequestedView>
            </t:FreeBusyViewOptions>
          </m:GetUserAvailabilityRequest>
        </soap:Body>
      </soap:Envelope>
    </EwsLogEntry>
    

    Have I found a bug here or am I doing something wrong?

    Thanks

    Graham King

All Replies

  • Thursday, November 05, 2009 1:03 PMGraham King Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    I have also tried the example in the GettingStarted.doc which comes with the RC.

    This only works after 1200 each day.  Before 1200, i.e. when the dates are the same (remember time is not included for some reason) the same exception I got on my code is generated.

    StartDate = DateTime.Now
    EndDate = DateTime.Now.AddHours(12)
    So before 1200 StartDate.Date == EndDate.Date.  After 1200 StartDate.Date != EndDate.Date.

    // Create a list of attendees for which to request availability
    // information and meeting time suggestions.
    List<AttendeeInfo> attendees = new List<AttendeeInfo>();
    attendees.Add("someone@contoso.com");
    attendees.Add("someoneelse@contoso.com");
    
    // Call the availability service.
    GetUserAvailabilityResults results = service.GetUserAvailability(
        attendees,
        new TimeWindow(DateTime.Now, DateTime.Now.AddHours(12)),
        AvailabilityData.FreeBusyAndSuggestions);
    
    


    Graham King
  • Thursday, November 05, 2009 4:42 PMDavid Claux - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer
    This is not a bug. The Availability service (server side, that is) doesn't support times in the time window. Besides, it only supports 24 hour periods, so make sure that your time window is at least 24 hours long.
    David Claux | Program Manager - Exchange Web Services
  • Friday, November 06, 2009 9:24 AMGraham King Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi David,

    THanks for the reply; the lack of time support and min 24 hour window explains a lot.

    Is there no way to search for availability within a 24 hour period or between two specific times (which are more than 24 hours apart, e.g. 0900 Monday - 1700 Tuesday)?

    Thanks

    Graham King
  • Friday, November 06, 2009 9:58 PMDavid Claux - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer

    Unfortunately, GetUserAvailability only supports full days, from 12AM to 12AM the next day. To search within a specific time window, you will have to filter the returned results client side.


    David Claux | Program Manager - Exchange Web Services