更新事件Update event

命名空间:microsoft.graphNamespace: microsoft.graph

更新 event 对象的属性。Update the properties of the event object.

更新事件开始或结束时间的时区时,首先找到支持的时区,以确保仅设置针对用户的邮箱服务器配置的时区。When updating the time zone of the start or end time of an event, first find the supported time zones to make sure you set only time zones that have been configured for the user's mailbox server.

权限Permissions

要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.

权限类型Permission type 权限(从最低特权到最高特权)Permissions (from least to most privileged)
委派(工作或学校帐户)Delegated (work or school account) Calendars.ReadWriteCalendars.ReadWrite
委派(个人 Microsoft 帐户)Delegated (personal Microsoft account) Calendars.ReadWriteCalendars.ReadWrite
应用程序Application Calendars.ReadWriteCalendars.ReadWrite

HTTP 请求HTTP request

PATCH /me/events/{id}
PATCH /users/{id | userPrincipalName}/events/{id}
PATCH /groups/{id}/events/{id}

PATCH /me/calendar/events/{id}
PATCH /users/{id | userPrincipalName}/calendar/events/{id}
PATCH /groups/{id}/calendar/events/{id}

PATCH /me/calendars/{id}/events/{id}
PATCH /users/{id | userPrincipalName}/calendars/{id}/events/{id}

PATCH /me/calendargroup/calendars/{id}/events/{id}
PATCH /users/{id | userPrincipalName}/calendargroup/calendars/{id}/events/{id}

PATCH /me/calendargroups/{id}/calendars/{id}/events/{id}
PATCH /users/{id | userPrincipalName}/calendargroups/{id}/calendars/{id}/events/{id}

请求标头Request headers

名称Name 类型Type 说明Description
AuthorizationAuthorization stringstring Bearer {token}。必需。Bearer {token}. Required.

请求正文Request body

在请求正文中,提供应更新的相关字段的值。请求正文中不包括的现有属性将保留其以前的值,或根据对其他属性值的更改重新计算。为了获得最佳性能,不应包括尚未更改的现有值。In the request body, supply the values for relevant fields that should be updated. Existing properties that are not included in the request body will maintain their previous values or be recalculated based on changes to other property values. For best performance you shouldn't include existing values that haven't changed.

属性Property 类型Type 说明Description
attendeesattendees 与会者Attendee 事件的与会者集合。The collection of attendees for the event.
bodybody ItemBodyItemBody 与事件相关联的邮件正文。The body of the message associated with the event.
categoriescategories String collectionString collection 与事件相关联的类别。The categories associated with the event.
endend DateTimeTimeZoneDateTimeTimeZone 事件结束的日期、时间和时区。The date, time, and time zone that the event ends.
importanceimportance StringString 事件的重要性。The importance of the event. 可能的值包括 lownormalhighThe possible values are: low, normal, high.
isAllDayisAllDay BooleanBoolean 如果事件持续一整天,则设置为 true。Set to true if the event lasts all day.
isOnlineMeetingisOnlineMeeting BooleanBoolean 若此事件包含联机会议信息则为 True,反之则为 falseTrue if this event has online meeting information, false otherwise. 默认为 false。Default is false. 可选。Optional.
isReminderOnisReminderOn BooleanBoolean 如果设置警报以提醒用户有事件,则设置为 true。Set to true if an alert is set to remind the user of the event.
位置location 位置Location 事件的位置。The location of the event.
locationslocations location 集合location collection 举办或参加活动的地点。The locations where the event is held or attended from. locationlocations 属性总是相互对应。The location and locations properties always correspond with each other. 如果更新 location 属性,locations 集合中所有以前的位置都将被删除并替换为新的 location 值。If you update the location property, any prior locations in the locations collection would be removed and replaced by the new location value.
onlineMeetingProvideronlineMeetingProvider onlineMeetingProviderTypeonlineMeetingProviderType 表示联机会议服务提供商。Represents the online meeting service provider. 可取值为:teamsForBusinessskypeForBusinessskypeForConsumerThe possible values are teamsForBusiness, skypeForBusiness, and skypeForConsumer. 可选。Optional.
recurrencerecurrence PatternedRecurrencePatternedRecurrence 事件的定期模式。The recurrence pattern for the event.
reminderMinutesBeforeStartreminderMinutesBeforeStart Int32Int32 事件开始时间(即提醒警报发生时间)之前的分钟数。The number of minutes before the event start time that the reminder alert occurs.
responseRequestedresponseRequested BooleanBoolean 如果发件人希望接收事件被接受或拒绝时的响应,则设置为 true。Set to true if the sender would like a response when the event is accepted or declined.
sensitivitysensitivity StringString 可能的值包括 normalpersonalprivateconfidentialThe possible values are: normal, personal, private, confidential.
showAsshowAs StringString 要显示的状态。The status to show. 可能的值包括 freetentativebusyoofworkingElsewhereunknownThe possible values are: free, tentative, busy, oof, workingElsewhere, unknown.
startstart DateTimeTimeZoneDateTimeTimeZone 事件的开始日期、时间和时区。The start date, time, and time zone of the event.
subjectsubject StringString 事件的主题行文本。The text of the event's subject line.

由于事件资源支持扩展,因此可以使用 PATCH 操作在现有事件实例的扩展自定义属性中添加、更新或删除自己的特定于应用的数据。Because the event resource supports extensions, you can use the PATCH operation to add, update, or delete your own app-specific data in custom properties of an extension in an existing event instance.

如果你正更新的事件是定期系列的主事件,包含多个与会者,并且具有已单独更新的实例,则将发送多个通知电子邮件:一个用于主系列,另一个用于已更新的实例。If the event you're updating is the master event of a recurring series, contains multiple attendees, and has instances that have been updated separately, multiple notification emails will be sent out: one for the master series and one per instance that has been updated.

响应Response

如果成功,此方法在响应正文中返回 200 OK 响应代码和更新的 event 对象。If successful, this method returns a 200 OK response code and updated event object in the response body.

注意: 此方法可以返回 HTTP 400 错误请求响应,错误代码为 ErrorOccurrenceCrossingBoundary,并显示以下错误消息:已修改的事件正在交叉或重叠相邻的事件。Note: This method can return an HTTP 400 Bad Request response with an error code of ErrorOccurrenceCrossingBoundary and the following error message: Modified occurrence is crossing or overlapping adjacent occurrence. 这表示更新违反了重复例外的以下 Outlook 限制:事件无法移动到上一次发生的日期或之前,并且无法移动到下一次发生的日期或之后。 This indicates that the update violates the following Outlook restriction on recurrence exceptions: an occurrence cannot be moved to or before the day of the previous occurrence, and cannot be moved to or after the day of the following occurrence.

示例Example

请求Request

下面是一个请求示例。Here is an example of the request.

PATCH https://graph.microsoft.com/v1.0/me/events/{id}
Content-type: application/json
Content-length: 285

{
  "originalStartTimeZone": "originalStartTimeZone-value",
  "originalEndTimeZone": "originalEndTimeZone-value",
  "responseStatus": {
    "response": "",
    "time": "datetime-value"
  },
  "recurrence": null,
  "iCalUId": "iCalUId-value",
  "reminderMinutesBeforeStart": 99,
  "isOnlineMeeting": true,
  "onlineMeetingProvider": "teamsForBusiness",
  "isReminderOn": true,
  "categories": ["Red category"]
}

响应Response

下面是一个响应示例。注意:为了简单起见,可能会将此处所示的响应对象截断。将从实际调用中返回所有属性。Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.

HTTP/1.1 200 OK
Content-type: application/json
Content-length: 285

{
  "originalStartTimeZone": "originalStartTimeZone-value",
  "originalEndTimeZone": "originalEndTimeZone-value",
  "responseStatus": {
    "response": "",
    "time": "datetime-value"
  },
  "recurrence": null,  
  "iCalUId": "iCalUId-value",
  "reminderMinutesBeforeStart": 99,
  "isOnlineMeeting": true,
  "onlineMeetingProvider": "teamsForBusiness",
  "isReminderOn": true,
  "onlineMeeting": {
        "joinUrl": "https://teams.microsoft.com/l/meetup-join/19%3ameeting_NzIyNzhlMGEtM2YyZC00ZmY0LTlhNzUtZmZjNWFmZGNlNzE2%40thread.v2/0?context=%7b%22Tid%22%3a%2272f988bf-86f1-41af-91ab-2d7cd011db47%22%2c%22Oid%22%3a%22bc55b173-cff6-457d-b7a1-64bda7d7581a%22%7d",
        "conferenceId": "177513992",
        "tollNumber": "+91 22 6241 6885"
  }
}

另请参阅See also