none
Need help to get a sample request for getUserAvailability RRS feed

  • Question

  • Hi Team,

    I am looking to make ews API call to getUserAvailability. Can someone please help me with the sample request where i can get free/busy data for say 6 days(consecutive) excluding weekends and also if there is a way I can get free/busy data for all the days from morning 7AM to 7PM for all the 6 days PST time.

    Wednesday, August 8, 2018 2:38 PM

All replies

  • Hi Anuj0801,

    Please try this code as below:

    private static void GetSuggestedMeetingTimesAndFreeBusyInfo(ExchangeService service)
    {
        // Create a collection of attendees. 
        List<AttendeeInfo> attendees = new List<AttendeeInfo>(); 
     
        attendees.Add(new AttendeeInfo() 
        { 
            SmtpAddress = "mack@contoso.com", 
            AttendeeType = MeetingAttendeeType.Organizer 
        }); 
     
        attendees.Add(new AttendeeInfo() 
        { 
            SmtpAddress = "sadie@contoso.com", 
            AttendeeType = MeetingAttendeeType.Required 
        }); 
     
        // Specify options to request free/busy information and suggested meeting times.
        AvailabilityOptions availabilityOptions = new AvailabilityOptions(); 
        availabilityOptions.GoodSuggestionThreshold = 49; 
        availabilityOptions.MaximumNonWorkHoursSuggestionsPerDay = 0;
        availabilityOptions.MaximumSuggestionsPerDay = 2;
        // Note that 60 minutes is the default value for MeetingDuration, but setting it explicitly for demonstration purposes.
        availabilityOptions.MeetingDuration = 60; 
        availabilityOptions.MinimumSuggestionQuality = SuggestionQuality.Good; 
        availabilityOptions.DetailedSuggestionsWindow = new TimeWindow(DateTime.Now.AddDays(1), DateTime.Now.AddDays(2));
        availabilityOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy;
     
        // Return free/busy information and a set of suggested meeting times. 
        // This method results in a GetUserAvailabilityRequest call to EWS.
        GetUserAvailabilityResults results = service.GetUserAvailability(attendees, 
                                                                         availabilityOptions.DetailedSuggestionsWindow, 
                                                                         AvailabilityData.FreeBusyAndSuggestions, 
                                                                         availabilityOptions); 
        // Display suggested meeting times. 
        Console.WriteLine("Availability for {0} and {1}", attendees[0].SmtpAddress, attendees[1].SmtpAddress); 
        Console.WriteLine(); 
     
        foreach (Suggestion suggestion in results.Suggestions) 
        { 
            Console.WriteLine("Suggested date: {0}\n", suggestion.Date.ToShortDateString()); 
            Console.WriteLine("Suggested meeting times:\n");
            foreach (TimeSuggestion timeSuggestion in suggestion.TimeSuggestions) 
            { 
                        Console.WriteLine("\t{0} - {1}\n", 
                                          timeSuggestion.MeetingTime.ToShortTimeString(), 
                                          timeSuggestion.MeetingTime.Add(TimeSpan.FromMinutes(availabilityOptions.MeetingDuration)).ToShortTimeString()); 
            } 
        }
                
        int i = 0;
        // Display free/busy times.
        foreach (AttendeeAvailability availability in results.AttendeesAvailability)
        {
            Console.WriteLine("Availability information for {0}:\n", attendees[i].SmtpAddress);
            foreach (CalendarEvent calEvent in availability.CalendarEvents)
            {
                Console.WriteLine("\tBusy from {0} to {1} \n", calEvent.StartTime.ToString(), calEvent.EndTime.ToString());
            }
            i++;
        }
    }

    For more information, please see Get free/busy information by using EWS in Exchange

    Hope it helps you.

    Thanks,

    Simon


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Thursday, August 9, 2018 7:22 AM
  • Hi Simon,

    Thank you so much for the reply.

    Can you please help me how we can pass the time slot like 7AM to 7PM for all the days we pass to the API and also how we are excluding the weekends free/busy information?

    Thanks and Regards,

    Anuj Jain

    Thursday, August 9, 2018 3:45 PM
  • I think you might try test and detail my code to know ExchangeService.GetUserAvailability class feature. This is Get free/busy information by using EWS in Exchange sample. For your second question, Could you please provider your tested result code or related issues for me ? Maybe we can close this post and you might create new post with your detail issue. Thanks for your understanding. 

    Thanks,

    Simon


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Friday, August 10, 2018 3:13 AM
  • Hi Simon,

    Thank you so much for you kind reply.

    I am looking to get merged free/busy calendar info of a list of users I pass.

    I want to know the request to pass so that I can get merged free/busy calendar info from morning 7AM to 7PM for the start and end date i pass excluding any weekends if there are any.

    Hope I am clear with my question?

    Thanks and Regards,

    Anuj Jain

    Friday, August 10, 2018 11:05 AM
  • Did you resolved your issue ? Hopefully updates for this. 

    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Tuesday, August 21, 2018 9:53 AM