使用Flow Service API将Microsoft Dynamics连接到Experience Platform
创建对象:
- 开发人员
阅读本指南,了解如何使用Flow Service API将您的Microsoft Dynamics源连接到Adobe Experience Platform。
快速入门
本指南要求您对 Adobe Experience Platform 的以下组件有一定了解:
使用Experience Platform API
有关如何成功调用Experience Platform API的信息,请参阅Experience Platform API快速入门指南。
以下部分提供了使用Flow Service API成功将Experience Platform连接到Dynamics帐户所需了解的其他信息。
收集所需的凭据
为了使Flow Service连接到Dynamics,您必须提供以下连接属性的值:
凭据 | 描述 |
---|---|
serviceUri | Dynamics实例的服务URL。 |
username | Dynamics用户帐户的用户名。 |
password | Dynamics帐户的密码。 |
凭据 | 描述 |
---|---|
servicePrincipalId | Dynamics帐户的客户端ID。 使用服务主体和基于密钥的身份验证时需要此ID。 |
servicePrincipalKey | 服务主体密钥。 使用服务主体和基于密钥的身份验证时需要此凭据。 |
有关入门的详细信息,请参阅此 Dynamics 文档。
创建基本连接
基本连接会保留源与Experience Platform之间的信息,包括源的身份验证凭据、连接的当前状态以及唯一的基本连接ID。 基本连接ID允许您浏览和浏览源中的文件,并标识要摄取的特定项目,包括有关其数据类型和格式的信息。
要创建基本连接ID,请在提供您的Dynamics身份验证凭据作为请求参数的一部分时,向/connections
端点发出POST请求。
API格式
POST /connections
要使用基本身份验证创建Dynamics基本连接,请在提供连接的serviceUri
、username
和password
的值时向Flow Service API发出POST请求。
请求
以下请求使用基本身份验证为Dynamics源创建基本连接。
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/connections' \
-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": "Dynamics connection",
"description": "Dynamics connection using basic auth",
"auth": {
"specName": "Basic Authentication for Dynamics-Online",
"params": {
"serviceUri": "{SERVICE_URI}",
"username": "{USERNAME}",
"password": "{PASSWORD}"
}
},
"connectionSpec": {
"id": "38ad80fe-8b06-4938-94f4-d4ee80266b07",
"version": "1.0"
}
}'
auth.params.serviceUri
auth.params.username
auth.params.password
connectionSpec.id
38ad80fe-8b06-4938-94f4-d4ee80266b07
响应
成功的响应返回新创建的基本连接,包括其唯一标识符(id
)。
{
"id": "4cb0c374-d3bb-4557-b139-5712880adc55",
"etag": "\"9e0052a2-0000-0200-0000-5e35tb330000\""
}
要使用基于服务主体密钥的身份验证创建Dynamics基本连接,请在提供连接的serviceUri
、servicePrincipalId
和servicePrincipalKey
的值时向Flow Service API发出POST请求。
请求
以下请求使用基于基本服务主体密钥的身份验证为Dynamics源创建基本连接。
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/connections' \
-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": "Dynamics connection",
"description": "Dynamics connection using key-based authentication",
"auth": {
"specName": "Service Principal Key Based Authentication",
"params": {
"serviceUri": "{SERVICE_URI}",
"servicePrincipalId": "{SERVICE_PRINCIPAL_ID}",
"servicePrincipalKey": "{SERVICE_PRINCIPAL_KEY}"
}
},
"connectionSpec": {
"id": "38ad80fe-8b06-4938-94f4-d4ee80266b07",
"version": "1.0"
}
}'
auth.params.serviceUri
auth.params.servicePrincipalId
auth.params.servicePrincipalKey
connectionSpec.id
38ad80fe-8b06-4938-94f4-d4ee80266b07
响应
成功的响应返回新创建的连接,包括其唯一标识符(id
)。
{
"id": "4cb0c374-d3bb-4557-b139-5712880adc55",
"etag": "\"9e0052a2-0000-0200-0000-5e35tb330000\""
}
浏览您的数据表
要浏览Dynamics数据表,请向/connections/{BASE_CONNECTION_ID}/explore
端点发出GET请求,并提供您的基本连接ID作为查询参数的一部分。
API格式
GET /connections/{BASE_CONNECTION_ID}/explore?objectType=root
{BASE_CONNECTION_ID}
请求
以下请求检索具有基础连接ID的Dynamics源的可用表和视图列表: dd668808-25da-493f-8782-f3433b976d1e
。
curl -X GET \
'https://platform.adobe.io/data/foundation/flowservice/connections/dd668808-25da-493f-8782-f3433b976d1e/explore?objectType=root' \
-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' \
响应
成功的响应返回根级别的Dynamics表和视图目录。
[
{
"type": "table",
"name": "systemuserlicenses",
"path": "systemuserlicenses",
"canPreview": true,
"canFetchSchema": true
},
{
"type": "table",
"name": "Process Dependency",
"path": "workflowdependency",
"canPreview": true,
"canFetchSchema": true
},
{
"type": "view",
"name": "accountView1",
"path": "accountView1",
"canPreview": true,
"canFetchSchema": true
},
{
"type": "view",
"name": "Inactive_ACC_custom",
"path": "Inactive_ACC_custom",
"canPreview": true,
"canFetchSchema": true
}
]
使用主键优化数据探索
通过将primaryKey
作为查询参数的一部分提供,您可以优化浏览查询。 将primaryKey
作为查询参数加入时,必须指定Dynamics表的主键。
API格式
GET /connections/{BASE_CONNECTION_ID}/explore?preview=true&object={OBJECT}&objectType={OBJECT_TYPE}&previewCount=10&primaryKey={PRIMARY_KEY}
{BASE_CONNECTION_ID}
preview
{OBJECT}
{OBJECT_TYPE}
previewCount
{PRIMARY_KEY}
请求
curl -X GET \
'https://platform-stage.adobe.io/data/foundation/flowservice/connections/dd668808-25da-493f-8782-f3433b976d1e/explore?preview=true&object=lead&objectType=table&previewCount=10&primaryKey=leadid' \
-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' \
检查表的结构
要检查特定表的结构,请向/connections/{BASE_CONNECTION_ID}/explore
发出GET请求,并将特定表的路径作为查询参数提供。
API格式
GET /connections/{BASE_CONNECTION_ID}/explore?object={TABLE_PATH}&objectType=table
{BASE_CONNECTION_ID}
{TABLE_PATH}
请求
以下请求检索路径为workflowdependency
的Dynamics表的结构和内容。
curl -X GET \
'https://platform.adobe.io/data/foundation/flowservice/connections/dd668808-25da-493f-8782-f3433b976d1e/explore?object=workflowdependency&objectType=table' \
-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' \
响应
成功的响应返回路径workflowdependency
的内容。
{
"format": "flat",
"schema": {
"columns": [
{
"name": "first_name",
"type": "string",
"meta": {
"originalType": "String"
}
},
{
"name": "last_name",
"type": "string",
"meta": {
"originalType": "String"
}
},
{
"name": "email",
"type": "string",
"meta": {
"originalType": "String"
}
}
]
}
}
检查视图的结构
在Dynamics中,视图是指要显示的列、每列的宽度、对记录列表进行排序的默认系统以及应用于限制列表中将显示哪些记录的默认筛选器。
要检查视图的结构,请向/connections/{BASE_CONNECTION_ID}/explore
发出GET请求,并在查询参数中指定视图路径。 此外,您必须将objectType
指定为view
。
API格式
GET /connections/{BASE_CONNECTION_ID}/explore?object={VIEW_PATH}&objectType=view
{BASE_CONNECTION_ID}
{VIEW_PATH}
请求
以下请求检索accountView1
。
curl -X GET \
'https://platform.adobe.io/data/foundation/flowservice/connections/dd668808-25da-493f-8782-f3433b976d1e/explore?object=accountView1&objectType=view' \
-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' \
响应
成功的响应返回accountView1
的结构。
{
"format": "flat",
"schema": {
"columns": [
{
"name": "name",
"type": "string",
"meta": {
"originalType": "string"
},
"xdm": {
"type": "string"
}
},
{
"name": "fetchxml",
"type": "string",
"meta": {
"originalType": "string"
},
"xdm": {
"type": "string"
}
},
{
"name": "querytype",
"type": "integer",
"meta": {
"originalType": "int"
},
"xdm": {
"type": "integer",
"minimum": -2147483648,
"maximum": 2147483647
}
},
{
"name": "userqueryid",
"type": "string",
"meta": {
"originalType": "guid"
},
"xdm": {
"type": "string"
}
}
]
}
}
预览实体类型视图
要预览视图的内容,请向/connections/{BASE_CONNECTION_ID}/explore
发出GET请求,并在查询参数中包含视图路径和preview=true
。
API格式
GET /connections/{BASE_CONNECTION_ID}/explore?object={VIEW_PATH}&preview=true&objectType=view
{BASE_CONNECTION_ID}
{VIEW_PATH}
请求
以下请求预览accountView1
的内容。
curl -X GET \
'https://platform.adobe.io/data/foundation/flowservice/connections/dd668808-25da-493f-8782-f3433b976d1e/explore?object=accountView1&preview=true&objectType=view' \
-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' \
响应
成功的响应返回accountView1
的内容。
{
"format": "flat",
"schema": {
"columns": [
{
"name": "emailaddress1",
"type": "string",
"meta": {
"originalType": "string"
},
"xdm": {
"type": "string"
}
},
{
"name": "contactid",
"type": "string",
"meta": {
"originalType": "guid"
},
"xdm": {
"type": "string"
}
},
{
"name": "fullname",
"type": "string",
"meta": {
"originalType": "string"
},
"xdm": {
"type": "string"
}
}
]
},
"data": [
{
"contactid": "396e19de-0852-ec11-8c62-00224808a1df",
"fullname": "Tim Barr",
"emailaddress1": "barrtim@googlemedia.com"
}
]
}
创建源连接以摄取视图
要创建源连接并摄取视图,请对/sourceConnections
端点发出POST请求,提供表名称,并在请求正文中将entityType
指定为view
。
API格式
POST /sourceConnections
请求
以下请求创建Dynamics源连接并摄取视图。
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": "Dynamics Source Connection",
"description": "Dynamics Source Connection",
"baseConnectionId": "dd668808-25da-493f-8782-f3433b976d1e",
"data": {
"format": "tabular",
"schema": null,
"properties": null
},
"params": {
"tableName": "Contacts with name TIM",
"entityType": "view"
},
"connectionSpec": {
"id": "38ad80fe-8b06-4938-94f4-d4ee80266b07",
"version": "1.0"
}
}'
响应
成功的响应会返回新生成的源连接ID及其相应的电子标记。
{
"id": "e566bab3-1b58-428c-b751-86b8cc79a3b4",
"etag": "\"82009592-0000-0200-0000-678121030000\""
}
使用主密钥优化数据流
您还可以通过指定主键作为请求正文参数的一部分来优化Dynamics数据流。
API格式
POST /sourceConnections
请求
将主键指定为contactid
时,以下请求创建Dynamics源连接。
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": "Dynamics Source Connection",
"description": "Dynamics Source Connection",
"baseConnectionId": "dd668808-25da-493f-8782-f3433b976d1e",
"data": {
"format": "tabular"
},
"params": {
"tableName": "contact",
"primaryKey": "contactid"
},
"connectionSpec": {
"id": "38ad80fe-8b06-4938-94f4-d4ee80266b07",
"version": "1.0"
}
}'
baseConnectionId
data.format
params.tableName
params.primaryKey
connectionSpec.id
响应
成功的响应会返回新生成的源连接ID及其相应的电子标记。
{
"id": "e566bab3-1b58-428c-b751-86b8cc79a3b4",
"etag": "\"82009592-0000-0200-0000-678121030000\""
}
后续步骤
通过完成本教程,您已使用Flow Service API创建了Microsoft Dynamics基本连接。 您可以在下列教程中使用此基本连接ID: