使用TimeConstraint的FindMeetingTimes返回ErrorInternalServerError

时间:2017-11-21 14:02:27

标签: microsoft-graph outlook-restapi

使用Graph API我正在提出类似于下面的请求。

出于某种原因,当我包含TimeConstraint时,我得到一个空指针。如果我不包含TimeConstraint节点,则会成功返回请求。

对我来说,我的TimeConstraint部分看起来不错。有什么不对或我错过了吗?

例外:

{
  "error": {
    "code": "ErrorInternalServerError",
    "message": "Object reference not set to an instance of an object.",
    "innerError": {
      "request-id": "905b8b0f-5de2-4559-861d-4244aa25da7c",
      "date": "2017-11-21T13:48:32"
    }
  }
}

请求:

{
   "Attendees":[
      {
         "type":"required",
         "emailAddress":{
            "address":"user1@tenant.com"
         }
      },
      {
         "type":"required",
         "emailAddress":{
            "address":"user2@tenant.com"
         }
      },
      {
         "type":"required",
         "emailAddress":{
            "address":"user3@tenant.com"
         }
      }
   ],
   "LocationConstraint":{
      "locations":[
         {
            "resolveAvailability":true,
            "locationEmailAddress":"room@tenant.com"
         }
      ]
   },
   "TimeConstraint":{
      "activityDomain":"work",
      "timeslots":[
         {
            "start":{
               "dateTime":"2017-11-26T09:00:00",
               "timeZone":"Pacific Standard Time"
            }
         },
         {
            "end":{
               "dateTime":"2017-11-26T17:00:00",
               "timeZone":"Pacific Standard Time"
            }
         }
      ]
   },
   "MeetingDuration":"PT1H",
   "MaxCandidates":99,
   "IsOrganizerOptional":false,
   "ReturnSuggestionReasons":true,
   "MinimumAttendeePercentage":100.0
}

1 个答案:

答案 0 :(得分:1)

您的开始and end`属性的范围太远了。这些是同一对象的属性:

请改为尝试:

"timeslots": [{
    "start": {
        "dateTime": "2017-11-23T16:58:07.973Z",
        "timeZone": "Eastern Standard Time"
    },
    "end": {
        "dateTime": "2017-11-30T16:58:07.973Z",
        "timeZone": "Eastern Standard Time"
    }
}]

使用Microsoft Graph .NET Client SDK时:

// Create TimeConstraint
TimeConstraint timeConstraint = new TimeConstraint();
timeConstraint.ActivityDomain = ActivityDomain.Unrestricted;

// Create a TimeSlot
TimeSlot timeSlot = new TimeSlot();
timeSlot.Start.DateTime = "2017-11-23T16:58:07.973Z";
timeSlot.Start.TimeZone = "Eastern Standard Time";
timeSlot.End.DateTime = "2017-11-30T16:58:07.973Z";
timeSlot.End.TimeZone = "Eastern Standard Time";

// Create a TimeSlot collection and add the TimeSlot
List<TimeSlot> timeSlots = new List<TimeSlot>();
timeSlots.Add(timeSlot);

// Assign the TimeSlot collection to the TimeContraint
timeConstraint.Timeslots = timeSlots;