使用API為Profile和Identity Service啟用資料集
本教學課程涵蓋啟用資料集以在Real-Time Customer Profile和Identity Service中使用的程式,並細分為下列步驟:
-
使用下列兩個選項之一,啟用資料集以用於Real-Time Customer Profile:
快速入門
若要參閱本教學課程,請先實際瞭解管理已啟用設定檔的資料集所牽涉到的多項Adobe Experience Platform服務。 在開始本教學課程之前,請先檢閱這些相關Experience Platform服務的檔案:
- Real-Time Customer Profile:根據來自多個來源的彙總資料,提供統一的即時消費者設定檔。
- Identity Service:透過橋接擷取到Experience Platform中的不同資料來源的身分來啟用Real-Time Customer Profile。
- Catalog Service: RESTful API可讓您建立資料集並為Real-Time Customer Profile和Identity Service設定資料集。
- Experience Data Model (XDM): Experience Platform用來組織客戶體驗資料的標準化架構。
以下章節提供您需瞭解的其他資訊,才能成功呼叫Experience Platform API。
讀取範例 API 呼叫
本教學課程提供範例API呼叫,示範如何格式化您的請求。 這些包括路徑、必要的標頭和正確格式化的請求承載。 此外,也提供 API 回應中傳回的範例 JSON。 如需文件中用於範例 API 呼叫的慣例相關資訊,請參閱 Experience Platform 疑難排解指南中的如何讀取範例 API 呼叫一節。
收集所需標頭的值
為了對 Experience Platform API 進行呼叫,您必須先完成驗證教學課程。 完成驗證教學課程會提供所有 Experience Platform API 呼叫中每個必要標頭的值,如下所示:
Authorization: Bearer {ACCESS_TOKEN}x-api-key: {API_KEY}x-gw-ims-org-id: {ORG_ID}
所有包含裝載(POST、PUT、PATCH)的要求都需要額外Content-Type標題。 必要時,此標頭的正確值會顯示在範例要求中。
Experience Platform中的所有資源都與特定的虛擬沙箱隔離。 對Experience Platform API的所有請求都需要x-sandbox-name標頭,以指定將在其中執行操作的沙箱名稱。 如需Experience Platform中沙箱的詳細資訊,請參閱沙箱概觀檔案。
建立為設定檔和身分啟用的資料集 create-a-dataset-enabled-for-profile-and-identity
您可以在建立資料集後或資料集建立後,立即為即時客戶設定檔和Identity Service啟用資料集。 如果要啟用已建立的資料集,請依照本檔案稍後所提供的設定現有資料集的步驟操作。
若要建立為設定檔啟用的資料集,您可以使用POST要求至/dataSets端點。
API格式
POST /dataSets
要求
藉由在要求內文中的tags下包含unifiedProfile和unifiedIdentity,資料集將分別立即啟用Profile和Identity Service。 這些標籤的值必須是包含字串"enabled:true"的陣列。
curl -X POST \
https://platform.adobe.io/data/foundation/catalog/dataSets \
-H 'Content-Type: application/json' \
-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 '{
"schemaRef": {
"id": "https://ns.adobe.com/{TENANT_ID}/schemas/31670881463308a46f7d2cb09762715",
"contentType": "application/vnd.adobe.xed-full-notext+json; version=1"
},
"tags": {
"unifiedProfile": ["enabled:true"],
"unifiedIdentity": ["enabled:true"]
}
}'
schemaRef.id{TENANT_ID}回應
成功的回應會顯示一個陣列,其中包含"@/dataSets/{DATASET_ID}"形式的新建立資料集識別碼。 當您成功建立並啟用資料集後,請繼續進行上傳資料的步驟。
[
"@/dataSets/5b020a27e7040801dedbf46e"
]
設定現有的資料集 configure-an-existing-dataset
下列步驟說明如何為Real-Time Customer Profile和Identity Service啟用先前建立的資料集。 如果您已建立已啟用設定檔的資料集,請繼續進行擷取資料的步驟。
檢查資料集是否已啟用 check-if-the-dataset-is-enabled
您可以使用Catalog API檢查現有的資料集,以判斷是否已啟用它以用於Real-Time Customer Profile和Identity Service。 以下呼叫會依ID擷取資料集的詳細資料。
API格式
GET /dataSets/{DATASET_ID}
{DATASET_ID}要求
curl -X GET \
'https://platform.adobe.io/data/foundation/catalog/dataSets/5b020a27e7040801dedbf46e' \
-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}'
回應
{
"5b020a27e7040801dedbf46e": {
"name": "Commission Program Events DataSet",
"imsOrg": "{ORG_ID}",
"tags": {
"adobe/pqs/table": [
"unifiedprofileingestiontesteventsdataset"
],
"unifiedProfile": [
"enabled:true"
],
"unifiedIdentity": [
"enabled:true"
]
},
"version": "1.0.1",
"created": 1536536917382,
"updated": 1539793978215,
"createdClient": "{CLIENT_CREATED}",
"createdUser": "{CREATED_BY}",
"updatedUser": "{CREATED_BY}",
"viewId": "5b020a27e7040801dedbf46f",
"files": "@/dataSetFiles?dataSetId=5b020a27e7040801dedbf46e",
"schema": "@/xdms/context/experienceevent",
"schemaRef": {
"id": "https://ns.adobe.com/xdm/context/experienceevent",
"contentType": "application/vnd.adobe.xed+json"
}
}
}
在tags屬性下,您可以看到unifiedProfile和unifiedIdentity都以值enabled:true存在。 因此,已分別為此資料集啟用Real-Time Customer Profile和Identity Service。
啟用資料集 enable-the-dataset
如果尚未為Profile或Identity Service啟用現有的資料集,您可以使用資料集ID發出PATCH請求來啟用它。
API格式
PATCH /dataSets/{DATASET_ID}
{DATASET_ID}要求
curl -X PATCH \
https://platform.adobe.io/data/foundation/catalog/dataSets/5b020a27e7040801dedbf46e \
-H 'Content-Type:application/json-patch+json' \
-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 '[
{ "op": "add", "path": "/tags/unifiedProfile", "value": ["enabled:true"] },
{ "op": "add", "path": "/tags/unifiedIdentity", "value": ["enabled:true"] }
]'
要求內文包含path到兩種型別的標籤: unifiedProfile和unifiedIdentity。 每個的value都是包含字串enabled:true的陣列。
回應
成功的PATCH要求會傳回HTTP狀態200 (確定)以及包含已更新資料集ID的陣列。 此ID應符合PATCH請求中傳送的ID。 unifiedProfile和unifiedIdentity標籤現已新增,且資料集已啟用供設定檔和身分識別服務使用。
[
"@/dataSets/5b020a27e7040801dedbf46e"
]
將資料擷取至資料集 ingest-data-into-the-dataset
Real-Time Customer Profile和Identity Service都會使用XDM資料,因為它正在擷取到資料集中。 如需如何將資料上傳到資料集的說明,請參閱有關使用API建立資料集的教學課程。 規劃要傳送至已啟用Profile之資料集的資料時,請考慮下列最佳實務:
- 包含您要用來作為分段條件的任何資料。
- 儘可能加入您從設定檔資料中確定的識別碼,以將您的身分圖表最大化。 這可讓Identity Service更有效率地拼接資料集中的身分。
確認由Real-Time Customer Profile擷取的資料 confirm-data-ingest-by-real-time-customer-profile
首次將資料上傳到新資料集時,或作為涉及新ETL或資料來源的程式的一部分,建議仔細檢查資料,以確保資料已按預期上傳。 使用Real-Time Customer Profile Access API,您可以在批次資料載入資料集時擷取該資料。 如果您無法擷取任何您期望的實體,您的資料集可能無法啟用Real-Time Customer Profile。 確認您的資料集已啟用後,請確保來源資料格式和識別碼支援您的期望。 如需有關如何使用Real-Time Customer Profile API存取Profile資料的詳細指示,請參閱entities端點指南,也稱為"Profile Access" API。
確認由Identity Service擷取的資料 confirm-data-ingest-by-identity-service
每個內嵌包含多個身分的資料片段,都會在您的私人身分圖形中建立連結。 如需身分圖表和存取身分資料的詳細資訊,請先閱讀身分識別服務概觀。