使用建立付款來源的資料流 Flow Service API
本教學課程涵蓋從付款來源擷取資料,並使用將其帶至Platform的步驟 Flow Service API.
- 為了建立資料流,您必須擁有付款來源的有效基底連線ID。 如果您沒有此ID,請參閱 來源概觀 以取得可建立基礎連線的付款來源清單。
- 為了讓Experience Platform擷取資料,所有以表格為基礎的批次來源的時區都必須設定為UTC。
快速入門
本教學課程需要您實際瞭解下列Adobe Experience Platform元件:
-
Experience Data Model (XDM) System:Experience Platform組織客戶體驗資料的標準化架構。
- 結構描述組合基本概念:瞭解XDM結構描述的基本建置區塊,包括結構描述組合中的關鍵原則和最佳實務。
- Schema Registry開發人員指南:包含您需瞭解的重要資訊,才能成功執行對Schema Registry API的呼叫。 這包括您的
{TENANT_ID}
、「容器」的概念,以及發出請求所需的標頭(請特別注意Accept標頭及其可能的值)。
-
Catalog Service:目錄是Experience Platform中資料位置和譜系的記錄系統。
-
Batch ingestion:批次擷取API可讓您將資料以批次檔案的形式擷取到Experience Platform中。
-
沙箱:Experience Platform提供的虛擬沙箱可將單一Platform執行個體分割成個別的虛擬環境,以利開發及改進數位體驗應用程式。
使用平台API
如需如何成功呼叫Platform API的詳細資訊,請參閱以下指南: Platform API快速入門.
建立來源連線 source
您可以透過向以下發出POST請求來建立來源連線: Flow Service API。 來源連線由連線ID、來源資料檔案的路徑以及連線規格ID組成。
若要建立來源連線,您也必須定義資料格式屬性的列舉值。
對檔案型聯結器使用下列列舉值:
delimited
json
parquet
對於所有表式聯結器,將值設定為 tabular
.
API格式
POST /sourceConnections
要求
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/sourceConnections' \
-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}' \
-H 'Content-Type: application/json' \
-d '{
"name": "PayPal source connection",
"baseConnectionId": "24151d58-ffa7-4960-951d-58ffa7396097",
"description": "PayPal source connection",
"data": {
"format": "tabular",
}
},
"params": {
"tableName": "PayPal.Catalog_Products",
"columns": [
{
"name": "Product_Id",
"type": "string",
"xdm": {
"type": "string"
}
},
{
"name": "Product_Name",
"type": "string",
"xdm": {
"type": "string"
}
},
{
"name": "Description",
"type": "string",
"xdm": {
"type": "string"
}
},
{
"name": "Create_Time",
"type": "string",
"meta:xdmType": "date-time",
"xdm": {
"type": "string",
"format": "date-time"
}
}
]
},
"connectionSpec": {
"id": "221c7626-58f6-4eec-8ee2-042b0226f03b",
"version": "1.0"
}
}'
baseConnectionId
params.path
connectionSpec.id
回應
成功的回應會傳回唯一識別碼(id
)。 在後續步驟中,建立目標連線時需要此ID。
{
"id": "2c48a152-3d49-43cb-88a1-523d49e3cbcb",
"etag": "\"8000c843-0000-0200-0000-5e8917ea0000\""
}
建立目標XDM結構描述 target-schema
為了在Platform中使用來源資料,必須建立目標結構描述,以根據您的需求來建構來源資料。 然後目標結構描述會用來建立包含來源資料的Platform資料集。
您可以透過對以下對象執行POST請求來建立目標XDM結構描述: 結構描述登入API.
如需如何建立目標XDM結構的詳細步驟,請參閱以下教學課程: 使用API建立結構描述.
建立目標資料集 target-dataset
您可以透過對執行POST請求來建立目標資料集 目錄服務API,在裝載中提供目標結構描述的ID。
如需如何建立目標資料集的詳細步驟,請參閱教學課程,位於 使用API建立資料集.
建立目標連線 target-connection
目標連線代表與擷取資料著陸目的地之間的連線。 若要建立目標連線,您必須提供與Data Lake相關聯的固定連線規格ID。 此連線規格ID為: c604ff05-7f1a-43c0-8e18-33bf874cb11c
.
您現在具有目標結構描述、目標資料集和到資料湖的連線規格ID的唯一識別碼。 使用 Flow Service API後,您可以指定這些識別碼,並將包含傳入來源資料的資料集,藉此建立目標連線。
API格式
POST /targetConnections
要求
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/targetConnections' \
-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}' \
-H 'Content-Type: application/json' \
-d '{
"name": "Target Connection for payments",
"description": "Target Connection for payments",
"data": {
"schema": {
"id": "https://ns.adobe.com/{TENANT_ID}/schemas/14d89c5bb88e2ff488f23db896be469e7e30bb166bda8722",
"version": "application/vnd.adobe.xed-full+json;version=1"
}
},
"params": {
"dataSetId": "5e8918669cbbee18ad9771f3"
},
"connectionSpec": {
"id": "221c7626-58f6-4eec-8ee2-042b0226f03b",
"version": "1.0"
}
}'
data.schema.id
$id
目標XDM結構描述的。data.schema.version
application/vnd.adobe.xed-full+json;version=1
,會傳回結構描述的最新次要版本。params.dataSetId
connectionSpec.id
c604ff05-7f1a-43c0-8e18-33bf874cb11c
.回應
成功回應會傳回新目標連線的唯一識別碼(id
)。 在後續步驟中需要此值,才能建立資料流。
{
"id": "c8e12917-ac33-44d7-a129-17ac3364d7b7",
"etag": "\"0f015874-0000-0200-0000-5e8918e60000\""
}
建立對應 mapping
為了將來源資料擷取到目標資料集中,必須首先將其對應到目標資料集所堅持的目標結構描述。
若要建立對應集,請向以下發出POST請求: mappingSets
的端點 Data Prep API 提供您的目標XDM結構描述時 $id
以及要建立的對應集詳細資訊。
API格式
POST /mappingSets
要求
curl -X POST \
'https://platform.adobe.io/data/foundation/conversion/mappingSets' \
-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}' \
-H 'Content-Type: application/json' \
-d '{
"version": 0,
"xdmSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/14d89c5bb88e2ff488f23db896be469e7e30bb166bda8722",
"xdmVersion": "1.0",
"id": null,
"mappings": [
{
"destinationXdmPath": "_id",
"sourceAttribute": "Product_Id",
"identity": false,
"identityGroup": null,
"namespaceCode": null,
"version": 0
},
{
"destinationXdmPath": "product.name",
"sourceAttribute": "Product_Name",
"identity": false,
"identityGroup": null,
"namespaceCode": null,
"version": 0
},
{
"destinationXdmPath": "product.description",
"sourceAttribute": "Description",
"identity": false,
"identityGroup": null,
"namespaceCode": null,
"version": 0
},
{
"destinationXdmPath": "product.type",
"sourceAttribute": "Type",
"identity": false,
"identityGroup": null,
"namespaceCode": null,
"version": 0
}
]
}'
xdmSchema
$id
目標XDM結構描述的。回應
成功的回應會傳回新建立的對應詳細資訊,包括其唯一識別碼(id
)。 在後續步驟中需要此ID才能建立資料流。
{
"id": "b54a8dc38e8d4e31a2dc096e413ae8e5",
"version": 0,
"createdDate": 1586043319604,
"modifiedDate": 1586043319604,
"createdBy": "{CREATED_BY}",
"modifiedBy": "{MODIFIED_BY}"
}
查詢資料流規格 specs
資料流負責從來源收集資料,並將這些資料匯入Platform。 若要建立資料流,您必須先透過對以下專案執行GET要求來取得資料流規格: Flow Service API。 資料流規格負責從外部資料庫或NoSQL系統收集資料。
API格式
GET /flowSpecs?property=name=="CRMToAEP"
要求
curl -X GET \
'https://platform.adobe.io/data/foundation/flowservice/flowSpecs?property=name=="CRMToAEP"' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
回應
成功的回應會傳回負責將資料從來源帶入Platform的資料流規格的詳細資料。 回應包含唯一的流量規格 id
建立新資料流時需要。
code language-json |
---|
|
建立資料流
收集資料的最後一步是建立資料流。 此時,您應該已準備下列必要值:
資料流負責從來源排程及收集資料。 您可以執行POST要求,同時在裝載中提供先前提到的值,藉此建立資料流。
若要排程內嵌,您必須先將開始時間值設為以秒為單位的epoch時間。 然後,您必須將頻率值設為五個選項之一: once
, minute
, hour
, day
,或 week
. 間隔值會指定兩個連續擷取之間的期間,而建立一次性擷取不需要設定間隔。 對於所有其他頻率,間隔值必須設定為等於或大於 15
.
API格式
POST /flows
要求
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/flows' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"name": "Dataflow between payments Platform",
"description": "Inbound data to Platform",
"flowSpec": {
"id": "14518937-270c-4525-bdec-c2ba7cce3860",
"version": "1.0"
},
"sourceConnectionIds": [
"2c48a152-3d49-43cb-88a1-523d49e3cbcb"
],
"targetConnectionIds": [
"c8e12917-ac33-44d7-a129-17ac3364d7b7"
],
"transformations": [
{
"name": "Copy",
"params": {
"deltaColumn": {
"name": "updatedAt",
"dateFormat": "YYYY-MM-DD",
"timezone": "UTC"
}
}
},
{
"name": "Mapping",
"params": {
"mappingId": "b54a8dc38e8d4e31a2dc096e413ae8e5",
"mappingVersion": 0
}
}
],
"scheduleParams": {
"startTime": "1567411548",
"frequency": "minute",
"interval":"30"
}
}'
flowSpec.id
sourceConnectionIds
targetConnectionIds
transformations.params.mappingId
transformations.params.deltaColum
deltaColumn
是 yyyy-MM-dd HH:mm:ss
.transformations.params.mappingId
scheduleParams.startTime
scheduleParams.frequency
once
, minute
, hour
, day
,或 week
.scheduleParams.interval
once
且應大於或等於 15
其他頻率值。回應
成功的回應會傳回ID id
建立資料流的URL名稱。
{
"id": "e0bd8463-0913-4ca1-bd84-6309134ca1f6",
"etag": "\"04004fe9-0000-0200-0000-5ebc4c8b0000\""
}
監視資料流
建立資料流後,您可以監視透過該資料流擷取的資料,以檢視有關資料流執行、完成狀態和錯誤的資訊。 如需如何監視資料流的詳細資訊,請參閱以下教學課程: 監視API中的資料流
後續步驟
依照本教學課程,您已建立來源聯結器,以依排程從付款應用程式收集資料。 傳入資料現在可供下游Platform服務使用,例如 Real-Time Customer Profile 和 Data Science Workspace. 如需更多詳細資訊,請參閱下列檔案: