// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Me.FindMeetingTimes;
using Microsoft.Graph.Beta.Models;
var requestBody = new FindMeetingTimesPostRequestBody
{
Attendees = new List<AttendeeBase>
{
new AttendeeBase
{
Type = AttendeeType.Required,
EmailAddress = new EmailAddress
{
Name = "Alex Wilbur",
Address = "alexw@contoso.com",
},
},
},
LocationConstraint = new LocationConstraint
{
IsRequired = false,
SuggestLocation = false,
Locations = new List<LocationConstraintItem>
{
new LocationConstraintItem
{
ResolveAvailability = false,
DisplayName = "Conf room Hood",
},
},
},
TimeConstraint = new TimeConstraint
{
ActivityDomain = ActivityDomain.Work,
TimeSlots = new List<TimeSlot>
{
new TimeSlot
{
Start = new DateTimeTimeZone
{
DateTime = "2019-04-16T09:00:00",
TimeZone = "Pacific Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2019-04-18T17:00:00",
TimeZone = "Pacific Standard Time",
},
},
},
},
IsOrganizerOptional = false,
MeetingDuration = TimeSpan.Parse("PT1H"),
ReturnSuggestionReasons = true,
MinimumAttendeePercentage = 100d,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.FindMeetingTimes.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.users.item.findmeetingtimes.FindMeetingTimesPostRequestBody findMeetingTimesPostRequestBody = new com.microsoft.graph.beta.users.item.findmeetingtimes.FindMeetingTimesPostRequestBody();
LinkedList<AttendeeBase> attendees = new LinkedList<AttendeeBase>();
AttendeeBase attendeeBase = new AttendeeBase();
attendeeBase.setType(AttendeeType.Required);
EmailAddress emailAddress = new EmailAddress();
emailAddress.setName("Alex Wilbur");
emailAddress.setAddress("alexw@contoso.com");
attendeeBase.setEmailAddress(emailAddress);
attendees.add(attendeeBase);
findMeetingTimesPostRequestBody.setAttendees(attendees);
LocationConstraint locationConstraint = new LocationConstraint();
locationConstraint.setIsRequired(false);
locationConstraint.setSuggestLocation(false);
LinkedList<LocationConstraintItem> locations = new LinkedList<LocationConstraintItem>();
LocationConstraintItem locationConstraintItem = new LocationConstraintItem();
locationConstraintItem.setResolveAvailability(false);
locationConstraintItem.setDisplayName("Conf room Hood");
locations.add(locationConstraintItem);
locationConstraint.setLocations(locations);
findMeetingTimesPostRequestBody.setLocationConstraint(locationConstraint);
TimeConstraint timeConstraint = new TimeConstraint();
timeConstraint.setActivityDomain(ActivityDomain.Work);
LinkedList<TimeSlot> timeSlots = new LinkedList<TimeSlot>();
TimeSlot timeSlot = new TimeSlot();
DateTimeTimeZone start = new DateTimeTimeZone();
start.setDateTime("2019-04-16T09:00:00");
start.setTimeZone("Pacific Standard Time");
timeSlot.setStart(start);
DateTimeTimeZone end = new DateTimeTimeZone();
end.setDateTime("2019-04-18T17:00:00");
end.setTimeZone("Pacific Standard Time");
timeSlot.setEnd(end);
timeSlots.add(timeSlot);
timeConstraint.setTimeSlots(timeSlots);
findMeetingTimesPostRequestBody.setTimeConstraint(timeConstraint);
findMeetingTimesPostRequestBody.setIsOrganizerOptional(false);
PeriodAndDuration meetingDuration = PeriodAndDuration.ofDuration(Duration.parse("PT1H"));
findMeetingTimesPostRequestBody.setMeetingDuration(meetingDuration);
findMeetingTimesPostRequestBody.setReturnSuggestionReasons(true);
findMeetingTimesPostRequestBody.setMinimumAttendeePercentage(100d);
var result = graphClient.me().findMeetingTimes().post(findMeetingTimesPostRequestBody, requestConfiguration -> {
requestConfiguration.headers.add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\FindMeetingTimes\FindMeetingTimesRequestBuilderPostRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Users\Item\FindMeetingTimes\FindMeetingTimesPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\AttendeeBase;
use Microsoft\Graph\Beta\Generated\Models\AttendeeType;
use Microsoft\Graph\Beta\Generated\Models\EmailAddress;
use Microsoft\Graph\Beta\Generated\Models\LocationConstraint;
use Microsoft\Graph\Beta\Generated\Models\LocationConstraintItem;
use Microsoft\Graph\Beta\Generated\Models\TimeConstraint;
use Microsoft\Graph\Beta\Generated\Models\ActivityDomain;
use Microsoft\Graph\Beta\Generated\Models\TimeSlot;
use Microsoft\Graph\Beta\Generated\Models\DateTimeTimeZone;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new FindMeetingTimesPostRequestBody();
$attendeesAttendeeBase1 = new AttendeeBase();
$attendeesAttendeeBase1->setType(new AttendeeType('required'));
$attendeesAttendeeBase1EmailAddress = new EmailAddress();
$attendeesAttendeeBase1EmailAddress->setName('Alex Wilbur');
$attendeesAttendeeBase1EmailAddress->setAddress('alexw@contoso.com');
$attendeesAttendeeBase1->setEmailAddress($attendeesAttendeeBase1EmailAddress);
$attendeesArray []= $attendeesAttendeeBase1;
$requestBody->setAttendees($attendeesArray);
$locationConstraint = new LocationConstraint();
$locationConstraint->setIsRequired(false);
$locationConstraint->setSuggestLocation(false);
$locationsLocationConstraintItem1 = new LocationConstraintItem();
$locationsLocationConstraintItem1->setResolveAvailability(false);
$locationsLocationConstraintItem1->setDisplayName('Conf room Hood');
$locationsArray []= $locationsLocationConstraintItem1;
$locationConstraint->setLocations($locationsArray);
$requestBody->setLocationConstraint($locationConstraint);
$timeConstraint = new TimeConstraint();
$timeConstraint->setActivityDomain(new ActivityDomain('work'));
$timeSlotsTimeSlot1 = new TimeSlot();
$timeSlotsTimeSlot1Start = new DateTimeTimeZone();
$timeSlotsTimeSlot1Start->setDateTime('2019-04-16T09:00:00');
$timeSlotsTimeSlot1Start->setTimeZone('Pacific Standard Time');
$timeSlotsTimeSlot1->setStart($timeSlotsTimeSlot1Start);
$timeSlotsTimeSlot1End = new DateTimeTimeZone();
$timeSlotsTimeSlot1End->setDateTime('2019-04-18T17:00:00');
$timeSlotsTimeSlot1End->setTimeZone('Pacific Standard Time');
$timeSlotsTimeSlot1->setEnd($timeSlotsTimeSlot1End);
$timeSlotsArray []= $timeSlotsTimeSlot1;
$timeConstraint->setTimeSlots($timeSlotsArray);
$requestBody->setTimeConstraint($timeConstraint);
$requestBody->setIsOrganizerOptional(false);
$requestBody->setMeetingDuration(new \DateInterval('PT1H'));
$requestBody->setReturnSuggestionReasons(true);
$requestBody->setMinimumAttendeePercentage(100);
$requestConfiguration = new FindMeetingTimesRequestBuilderPostRequestConfiguration();
$headers = [
'Prefer' => 'outlook.timezone="Pacific Standard Time"',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->me()->findMeetingTimes()->post($requestBody, $requestConfiguration)->wait();