標籤端點

資料使用標籤可讓您根據可能適用於該資料的使用原則來分類資料。 此 /labels 中的端點 Policy Service API 可讓您以程式設計方式管理體驗應用程式中的資料使用標籤。

NOTE
/labels 端點僅用於擷取、建立和更新資料使用標籤。 如需如何使用API呼叫將標籤新增至資料集和欄位的步驟,請參閱的指南 管理資料集標籤.

快速入門

本指南中使用的API端點屬於 Policy Service API. 在繼續之前,請檢閱 快速入門手冊 如需相關檔案的連結,請參閱本檔案範例API呼叫的指南,以及有關成功呼叫任何專案所需標題的重要資訊 Experience Platform API。

擷取標籤清單 list

您可以列出所有 corecustom 向發出GET請求以貼上標籤 /labels/core/labels/custom,依序輸入。

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