以下实现在2019年3月18日之前可以正常运行。
var graphClient = this.graphService.GraphClient;
var reqUrl = graphClient
.Me
.Request()
.RequestUrl;
reqUrl += "/findMeetingTimes";
var headers = new Dictionary<string, string>
{ { "Prefer", $"outlook.timezone = \"{parameter.PreferredTimeZone}\"" },
};
var noOfMeetingSlots = parameter.MaxCandidates ?? 5;
parameter.MaxCandidates = 25;
var hrm = this.graphService.CreateHttpPostRequest<MeetingSuggestionParameter>(
parameter,
new Uri(reqUrl),
headers);
await graphClient
.AuthenticationProvider
.AuthenticateRequestAsync(hrm)
.ConfigureAwait(false);
MeetingSuggestionResult result = null;
try
{
using(HttpResponseMessage response = await graphClient
.HttpProvider
.SendAsync(hrm)
.ConfigureAwait(false)) {
例外:
graphClient.HttpProvider.SendAsync throws 403 Forbidden.
Exception Message:
Code: UnknownError
Inner error
StackTrace
at Microsoft.Graph.HttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Publicis.Marcel.Services.Calendar.CalendarService.FindMeetingSuggesstionsWithParametersAsync(MeetingSuggestionParameter parameter) in E: \Assistant2\o365\Services\Publicis.Marcel.Services.Calendar\Concrete\CalendarService.cs:line
以下代码段可以在Client SDK中使用:
var re = await graphClient
.Me
.FindMeetingTimes(
Attendees,
null,
null,
new Duration(parameter.MeetingDuration),
parameter.MaxCandidates,
parameter.IsOrganizerOptional,
parameter.ReturnSuggestionReasons,
parameter.MinimumAttendeePercentage)
.Request()
.PostAsync()
.ConfigureAwait(false);
我已经检查过的东西
caledar.read
和calendar.read.Shared
这一直在生产中,直到2019年3月18日它开始抛出403 Forbidden
。