创建书签

命名空间: microsoft.graph.search

创建新 书签 对象。

API 可用性

此 API 可用于以下国家级云部署。

全局服务 美国政府 L4 美国政府 L5 (DOD) 由世纪互联运营的中国
✅ ❌ ❌ ❌

权限

为此 API 选择标记为最低特权的权限。 只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。

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

HTTP 请求

POST /search/bookmarks

请求标头

名称 说明
Authorization 持有者 {token}。 必填。 详细了解 身份验证和授权。
Content-Type application/json. 必需。

请求正文

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

下表显示了创建 书签时可用的属性。

属性 类型 说明
availabilityEndDateTime DateTimeOffset 书签停止作为搜索结果显示的日期和时间。 设置为 null “始终可用”。 时间戳类型使用 ISO 8601 格式表示日期和时间信息,并且始终采用 UTC 格式。 例如,2014 年 1 月 1 日午夜 UTC 为 2014-01-01T00:00:00Z。
availabilityStartDateTime DateTimeOffset 书签开始显示为搜索结果的日期和时间。 设置为 null “始终可用”。 时间戳类型使用 ISO 8601 格式表示日期和时间信息,并且始终采用 UTC 格式。 例如,2014 年 1 月 1 日午夜 UTC 为 2014-01-01T00:00:00Z。
类别 String collection 通常用于描述此书签的类别。 例如, IT 和 HR。
description String 搜索结果页上显示的书签说明。 继承自 searchAnswer。
displayName String 搜索结果中显示的书签名称。 继承自 searchAnswer。
groupIds String collection 能够查看此书签的安全组的列表。
keywords microsoft.graph.search.answerKeyword 触发此书签在搜索结果中显示的关键字。
languageTags 字符串集合 可在其中查看此书签的地理特定语言名称列表。 每个语言标记值都遵循 {language}-{region} 模式。 例如, en-us 是美国使用的英语。 有关可能值的列表,请参阅 支持的语言标记。
平台 microsoft.graph.devicePlatformType 集合 能够查看此书签的设备和操作系统的列表。 可能的值包括 android、windows、ios、unknown、macOs。
powerAppIds 字符串集合 与此书签关联的 Power Apps 列表。 如果用户将现有 Power Apps 添加到书签,则可以直接在搜索结果页面上完成任务,例如输入休假时间或报告支出。
state microsoft.graph.search.answerState 书签的状态。 可能的值包括 published、draft、excluded、unknownFutureValue。
targetedVariations microsoft.graph.search.answerVariant 集合 不同国家/地区或设备的书签变体。 当需要根据用户的设备、国家/地区或两者向不同内容时使用。 日期和组设置适用于所有变体。
webUrl String 书签的 URL 链接。 当用户从搜索结果中选择此书签时,他们将被定向到指定的 URL。 继承自 searchAnswer。

响应

如果成功,此方法将返回带有 201 Created 所创建书签 ID 的响应代码。

示例

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/v1.0/search/bookmarks
Content-Type: application/json

{
  "displayName": "Contoso Install Site",
  "webUrl": "http://www.contoso.com/",
  "description": "Try or buy Contoso for Home or Business and view product information",
  "keywords":  {
    "keywords": ["Contoso", "install"],
    "reservedKeywords": ["Unique keyword"],
    "matchSimilarKeywords": true
  },
  "availabilityStartDateTime": null,
  "availabilityEndDateTime": null,
  "platforms": ["windows"],
  "targetedVariations": [
    {
      "languageTag": "es-es",
      "displayName": "Sitio de instalación Contoso",
      "description": "Pruebe o compre Contoso hogar o negocios y vea la información del producto"
    }
  ],
  "state": "published"
}

响应

以下示例显示了相应的响应。

HTTP/1.1 201 Created
Location: /733b26d5-af76-4eea-ac69-1a0ce8716897
Content-Type: application/json

{
  "id": "733b26d5-af76-4eea-ac69-1a0ce8716897"
}