标签端点

数据使用标签允许您根据可能应用于数据的使用策略将数据分类。 此 /labels 中的端点 Policy Service API 允许您以编程方式管理体验应用程序中的数据使用标签。

NOTE
/labels 端点仅用于检索、创建和更新数据使用标签。 有关如何使用API调用向数据集和字段添加标签的步骤,请参阅上的指南 管理数据集标签.

快速入门

本指南中使用的API端点是 Policy Service API. 在继续之前,请查看 快速入门指南 有关相关文档的链接、阅读本文档中的示例API调用的指南,以及有关成功调用任何组件所需的所需标头的重要信息 Experience Platform API。

检索标签列表 list

您可以列出所有 corecustom 向以下对象发出GET请求以粘贴标签 /labels/core/labels/custom、ID名称和ID名称等。

API格式

GET /labels/core
GET /labels/custom

请求

以下请求列出了在您的组织下创建的所有自定义标签。

curl -X GET \
  'https://platform.adobe.io/data/foundation/dulepolicy/labels/custom' \
  -H 'Authorization: Bearer {ACCESS_TOKEN}' \
  -H 'x-api-key: {API_KEY}' \
  -H 'x-gw-ims-org-id: {ORG_ID}' \
  -H 'x-sandbox-name: {SANDBOX_NAME}'

响应

成功的响应将返回从系统中检索到的自定义标签列表。 由于上述示例请求是向 /labels/custom,则下面的响应仅显示自定义标签。

{
    "_page": {
        "count": 2
    },
    "_links": {
        "page": {
            "href": "https://platform.adobe.io:443/data/foundation/dulepolicy/labels/custom?{?limit,start,property}",
            "templated": true
        }
    },
    "children": [
        {
            "name": "L1",
            "category": "Custom",
            "friendlyName": "Banking Information",
            "description": "Data containing banking information for a customer.",
            "imsOrg": "{ORG_ID}",
            "sandboxName": "{SANDBOX_NAME}",
            "created": 1594396718731,
            "createdClient": "{CLIENT_ID}",
            "createdUser": "{USER_ID}",
            "updated": 1594396718731,
            "updatedClient": "{CLIENT_ID}",
            "updatedUser": "{USER_ID}",
            "_links": {
                "self": {
                    "href": "https://platform.adobe.io:443/data/foundation/dulepolicy/labels/custom/L1"
                }
            }
        },
        {
            "name": "L2",
            "category": "Custom",
            "friendlyName": "Purchase History Data",
            "description": "Data containing information on past transactions",
            "imsOrg": "{ORG_ID}",
            "sandboxName": "{SANDBOX_NAME}",
            "created": 1594397415663,
            "createdClient": "{CLIENT_ID}",
            "createdUser": "{USER_ID}",
            "updated": 1594397728708,
            "updatedClient": "{CLIENT_ID}",
            "updatedUser": "{USER_ID}",
            "_links": {
                "self": {
                    "href": "https://platform.adobe.io:443/data/foundation/dulepolicy/labels/custom/L2"
                }
            }
        }
    ]
}

查找标签 look-up

您可以通过包含特定标签的 name 属性位于GET请求的路径中 Policy Service API。

API格式

GET /labels/core/{LABEL_NAME}
GET /labels/custom/{LABEL_NAME}
参数
描述
{LABEL_NAME}
name 要查找的自定义标签的属性。

请求

以下请求检索自定义标签 L2,如路径中所示。

curl -X GET \
  'https://platform.adobe.io/data/foundation/dulepolicy/labels/custom/L2' \
  -H 'Authorization: Bearer {ACCESS_TOKEN}' \
  -H 'x-api-key: {API_KEY}' \
  -H 'x-gw-ims-org-id: {ORG_ID}' \
  -H 'x-sandbox-name: {SANDBOX_NAME}'

响应

成功的响应将返回自定义标签的详细信息。

{
    "name": "L2",
    "category": "Custom",
    "friendlyName": "Purchase History Data",
    "description": "Data containing information on past transactions",
    "imsOrg": "{ORG_ID}",
    "sandboxName": "{SANDBOX_NAME}",
    "created": 1594397415663,
    "createdClient": "{CLIENT_ID}",
    "createdUser": "{USER_ID}",
    "updated": 1594397728708,
    "updatedClient": "{CLIENT_ID}",
    "updatedUser": "{USER_ID}",
    "_links": {
        "self": {
            "href": "https://platform.adobe.io:443/data/foundation/dulepolicy/labels/custom/L2"
        }
    }
}

创建或更新自定义标签 create-update

PUT要创建或更新自定义标签,您必须向 Policy Service API。

API格式

PUT /labels/custom/{LABEL_NAME}
参数
描述
{LABEL_NAME}
name 自定义标签的属性。 如果不存在具有此名称的自定义标签,则会创建新标签。 如果存在,则将更新该标签。

请求

以下请求将创建一个新标签, L3,用于描述包含与客户所选支付计划相关的信息的数据。

curl -X PUT \
  'https://platform.adobe.io/data/foundation/dulepolicy/labels/custom/L3' \
  -H 'Authorization: Bearer {ACCESS_TOKEN}' \
  -H 'x-api-key: {API_KEY}' \
  -H 'x-gw-ims-org-id: {ORG_ID}' \
  -H 'x-sandbox-name: {SANDBOX_NAME}' \
  -d '{
        "name": "L3",
        "category": "Custom",
        "friendlyName": "Payment Plan",
        "description": "Data containing information on selected payment plans."
      }'
属性
描述
name
标签的唯一字符串标识符。 此值用于查找目的,并将标签应用于数据集和字段,因此建议该值简短明了。
category
标签的类别。 虽然您可以为自定义标签创建自己的类别,但强烈建议您使用 Custom 是否希望标签显示在UI中。
friendlyName
标签的友好名称,用于显示目的。
description
(可选)提供进一步上下文的标签描述。

响应

成功的响应会返回自定义标签的详细信息,如果更新了现有标签,则返回HTTP代码为200 (确定);如果创建了新标签,则返回201 (创建)。

{
  "name": "L3",
  "category": "Custom",
  "friendlyName": "Payment Plan",
  "description": "Data containing information on selected payment plans.",
  "imsOrg": "{ORG_ID}",
  "sandboxName": "{SANDBOX_NAME}",
  "created": 1529696681413,
  "createdClient": "{CLIENT_ID}",
  "createdUser": "{USER_ID}",
  "updated": 1529697651972,
  "updatedClient": "{CLIENT_ID}",
  "updatedUser": "{USER_ID}",
  "_links": {
    "self": {
      "href": "https://platform.adobe.io:443/data/foundation/dulepolicy/labels/custom/L3"
    }
  }
}

后续步骤

本指南介绍如何使用 /labels 策略服务API中的端点。 有关如何将标签应用于数据集和字段的步骤,请参阅 数据集标签API指南.

recommendation-more-help
834e0cae-2761-454a-be4d-62f0fd4b4456