创建或替换 historyItem

命名空间:microsoft.graph

重要

Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。

为现有用户活动创建新的或替换现有历史记录项。

Permissions

要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限

权限类型 权限(从最低特权到最高特权)
委派(工作或学校帐户) UserActivity.ReadWrite.CreatedByApp
委派(个人 Microsoft 帐户) UserActivity.ReadWrite.CreatedByApp
应用程序 不支持。

HTTP 请求

PUT /me/activities/{id}/historyItems/{id}

ID 需要为 GUID。

请求头

名称 类型 说明
Authorization string Bearer {token}。必需。

请求正文

在请求正文中,提供 historyItem 对象的 JSON 表示形式。

响应

如果成功,如果创建 201 Created historyItem 或 200 OK 替换 historyItem,此方法将返回 响应代码。

示例

请求

下面是一个请求示例。

PUT https://graph.microsoft.com/beta/me/activities/13881113971988980728/historyItems/390e06e2-7e5b-4133-8014-fac7ac5991af
Content-type: application/json

{
    "startedDateTime": "2015-02-11T20:54:04.3457274+00:00",
    "userTimezone": "Africa/Casablanca",
    "lastActiveDateTime": "2015-02-11T20:54:04.3457274+00:00"
}

响应

下面是一个响应示例。

HTTP/1.1 200 OK
Content-Type: application/json

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#users('user%40contoso.com')/activities('13881113971988980728')/historyItems/$entity",
    "status": "updated",
    "userTimezone": "Africa/Casablanca",
    "createdDateTime": "2018-02-26T20:28:22.14Z",
    "lastModifiedDateTime": "2018-02-26T20:28:22.155Z",
    "id": "9d0b74e4-4b41-43ea-b34d-f9c1bf9f809c",
    "startedDateTime": "2018-02-26T20:54:04.345Z",
    "lastActiveDateTime": "2018-02-26T20:54:24.345Z",
    "expirationDateTime": "2018-03-28T20:28:22.14Z",
    "activeDurationSeconds": 20
}