編輯

共用方式為


Replace timeOff

Namespace: microsoft.graph

Replace an existing timeOff object.

If the specified timeOff object doesn't exist, this method returns 404 Not found.

Permissions

Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

Permission type Least privileged permissions Higher privileged permissions
Delegated (work or school account) Group.Read.All Schedule.ReadWrite.All, Group.ReadWrite.All
Delegated (personal Microsoft account) Not supported. Not supported.
Application Schedule.ReadWrite.All Not available.

Note: This API supports admin permissions. Users with admin roles can access groups that they are not a member of.

HTTP request

PUT /teams/{teamId}/schedule/timesOff/{timeOffId}

Request headers

Header Value
Authorization Bearer {token}. Required. Learn more about authentication and authorization.
Content-Type application/json. Required.
MS-APP-ACTS-AS A user ID (GUID). Required only if the authorization token is an application token; otherwise, optional.

Request body

In the request body, supply only the values for properties to update. Existing properties that aren't included in the request body maintain their previous values or are recalculated based on changes to other property values.

The following table specifies the properties that can be updated.

Property Type Description
draftTimeOff timeOffItem The draft version of this timeOff item that is viewable by managers. It must be shared before it is visible to team members. Either draftOpenShift or sharedOpenShift should be null.
isStagedForDeletion Boolean The timeOff is marked for deletion, a process that is finalized when the schedule is shared. Optional
sharedTimeOff timeOffItem The shared version of this timeOff that is viewable by both employees and managers. Updates to the sharedTimeOff property send notifications to users in the Teams client. Either draftOpenShift or sharedOpenShift should be null.
userId String ID of the user assigned to the timeOff. Required.

Response

If successful, this method returns a 204 No Content response code and empty content. If the request specifies the Prefer header with return=representation preference, then this method returns a 200 OK response code and a timeOff object in the response body.

Example

Request

The following example shows a request.

PUT https://graph.microsoft.com/v1.0/teams/{teamId}/schedule/timesOff/{timeOffId}
Content-type: application/json

{
  "userId": "aa162a04-bec6-4b81-ba99-96caa7b2b24d",
  "sharedTimeOff": {
    "timeOffReasonId": "TOR_29a5ba96-c7ef-4e76-bec6-055323746314",
    "startDateTime": "2024-10-10T19:00:00Z",
    "endDateTime": "2024-10-10T20:00:00Z",
    "theme": "blue"
  },
  "draftTimeOff": null
}

Response

The following example shows the response.

HTTP/1.1 204 No Content