其他操作 additional-operations

排序 sorting

默认情况下,排序以升序方式提供。 要按降序排序,请将​ %20desc ​附加到​ _order ​参数的值。

要了解某个字段是否可以排序,请将“可排序”参数检查到资源元数据中。 如需详细信息,请参阅此小节

示例请求

  • 用于检索数据库中按字母顺序排序的电子邮件的示例GET请求。

    code language-none
    -X GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/profile/email?_order=email \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <ACCESS_TOKEN>' \
    -H 'Cache-Control: no-cache' \
    -H 'X-Api-Key: <API_KEY>'
    

    对请求的响应。

    code language-none
    {
    "content": [
        "adam@email.com",
        "allison.durance@example.com",
        "amy.dakota@mail.com",
        "andrea.johnson@mail.com",
        ...
    ]
    ...
    }
    
  • 用于以降序Alpha顺序检索数据库中的电子邮件的示例GET请求。

    code language-none
    -X GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/profile/email?_order=email%20desc \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <ACCESS_TOKEN>' \
    -H 'Cache-Control: no-cache' \
    -H 'X-Api-Key: <API_KEY>'
    

    对请求的响应。

    code language-none
    {
    "content": [
        "tombinder@example.com",
        "tombinder@example.com",
        "timross@example.com",
        "john.smith@example.com",
        ...
    ]
    }
    

筛选 filtering

检索过滤器元数据

每个资源都可以使用过滤器。 要确定与资源关联的过滤器,您需要对资源元数据执行GET请求。 此请求会返回URL,其中为给定资源定义了所有过滤器。 有关元数据的详细信息,请参阅此章节

要识别过滤器的元数据并确定其使用方式,您必须对之前返回的URL执行GET请求。

示例请求

以下负载示例说明如何为“profile”资源检索“byText”过滤器元数据。 首先对“profile”资源元数据执行GET请求。

-X GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/resourceType/profile \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-H 'Cache-Control: no-cache' \
-H 'X-Api-Key: <API_KEY>'

它会返回描述过滤器的URL。

{
"filters": {
        "href": "https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/resourceType/<PKEY>/filters/"
    }
  }

对URL执行GET请求。 它会返回用户档案资源的过滤器列表,其中包含与每个过滤器关联的元数据。

{
"birthday": {
        "PKey": "@FL-CbDFXbnHbXcVpeCGWL46VXJLn1LqxLMPagt2vz8sCxQ52lvB15KiUaxXkxJYQw-tZXYrgUWG6K8QcB4gxVY9RKoba5bRFY3294YFshDmorRr8",
        "category": "0150_profile",
        "condition": ...,
        "data": "https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/profile/birthday?type=$value&precision=$value&operator=$value&day=$value&month=$value&includeStart=$value&endDay=$value&endMonth=$value&includeEnd=$value&relativeValue=$value&nextUnitsValue=$value&previousUnitsValue=$value",
        "formType": "webPage",
        "fragmentName": "",
        "label": "Birthday",
}

筛选器元数据结构

每个过滤器都可以使用相同的元数据结构:

  • @formType ​和​ @webPage ​字段是技术字段。
  • data ​字段提供了如何使用过滤器的示例。
  • 元数据 ​节点描述了筛选器参数。
  • 条件 ​节点描述了筛选器的用途。 元数据节点中描述的过滤器参数用于创建过滤器条件。 对于每个筛选条件,如果​ enabledIf ​为true,将应用​ expr

筛选元数据结构示例:

"byText": {
        "PKey": "...",
        "category": "99_none",
        "condition": ...,
        "data": "/profileAndServices/profile/byText?text=$value",
        "formType": "none",
        "fragmentName": "",
        "label": "By name or email",
    }

使用过滤器

筛选对以下请求执行:

GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/<resourceName>/by<filterName>?<filterParam>=<filterValue>

可以在单个请求中组合多个过滤器:

GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/<resourceName>/<filter1name>/<filter2name>?<filter1param>=<filter1value>&<filter2param>=<filter2value>

示例请求

  • 用于检索类型为“email”的“service”资源的示例GET请求。

    code language-none
    -X GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/service/byChannel?channel=email \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <ACCESS_TOKEN>' \
    -H 'Cache-Control: no-cache' \
    -H 'X-Api-Key: <API_KEY>'
    

    对请求的响应。

    code language-none
    {
        "content": [
            {
                "PKey": "<PKEY>",
                "created": "2019-09-25 23:20:35.000Z",
                "href": "https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/service/@I_FIiDush4OQPc0mbOVR9USoh36Tt5CsD35lATvQjdWlXrYc0lFkvle2XIwZUbD8GqTVvSp8AfWFUvjkGMe1fPe5nok",
                "label": "Marketing Newsletter",
                "lastModified": "2019-09-25 23:20:35.000Z",
                "limitedDuration": false,
                "messageType": "email",
                "mode": "newsletter",
                ...
            },
            ...
        ],
        ...
    }
    
  • 用于检索中包含“Doe”的“profile”资源的示例GET请求
    电子邮件或姓氏字段(byText过滤器会搜索电子邮件和姓氏字段)。

    code language-none
    -X GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/profile/byText?text=Doe \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <ACCESS_TOKEN>' \
    -H 'Cache-Control: no-cache' \
    -H 'X-Api-Key: <API_KEY>'
    

    对请求的响应。

    code language-none
    {
        "content": [
            {
                "PKey": "<PKEY>",
                "firstName": "John",
                "lastName":"Doe",
                "birthDate": "1980-10-24",
                ...
            }
            ...
        ],
        ...
    }
    
  • 用于检索类型为“email”且标签为“sport”的服务资源的示例GET请求。

    code language-none
    -X GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/service/byChannel/byText?channel=email&text=sport \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <ACCESS_TOKEN>' \
    -H 'Cache-Control: no-cache' \
    -H 'X-Api-Key: <API_KEY>'
    

    对请求的响应。

    code language-none
    {
        "content": [
            {
                "PKey": "<PKEY>",
                "created": "2019-09-26 09:36:01.014Z",
                "href": "https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/service/<PKEY>",
                "label": "sport",
                "lastModified": "2019-09-26 09:36:01.014Z",
                "limitedDuration": false,
                "messageType": "email",
                "mode": "newsletter",
                "name": "SVC13",
                ...
            }
        ],
        ...
    }
    

自定义过滤器

如果要使用自定义筛选器,则必须在Adobe Campaign Standard界面中创建和自定义该筛选器。 之后,自定义筛选器的行为将与现成筛选器相同:

GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServicesExt/<resourceName>/by<customFilterName>?<customFilterparam>=<customFilterValue>

有关更多信息,请参阅Campaign Standard文档:

示例请求

用于检索交易额为100$或更大的“profile”资源的示例GET请求。 请注意,“byAmount”过滤器首先是在Adobe Campaign Standard界面中定义,并链接到“Transaction”自定义表。

-X GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServicesExt/profile/byAmount?amount_parameter=100 \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-H 'Cache-Control: no-cache' \
-H 'X-Api-Key: <API_KEY>'

计数 counting

Adobe Campaign REST API可以计算请求中的记录数。 为此,请使用​ count ​节点中返回的URL。

示例请求

要计数其​ messageType ​值等于“sms”的所有服务,请使用​ byChannel ​筛选器执行GET请求。

-X GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/service/byChannel?channel=sms \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-H 'Cache-Control: no-cache' \
-H 'X-Api-Key: <API_KEY>'

它会返回与过滤器对应的服务。

{
    "content": [
        {
            ...
            "messageType": "sms",
            "mode": "newsletter",
            "name": "SVC6",
            ...
        },
        ...
    ],
    "count": {
        "href": "https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/service/byChannel/_count?channel=sms&_lineStart=@iKTZ2q3IiSEDqZ5Nw1vdoGnQCqF-8DAUJRaVwR9obqqTxhMy"
    },
    "serverSidePagination": true
}

对​ count ​节点的URL执行GET请求以检索结果数。

-X GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/service/byChannel/_count?channel=sms&_lineStart=@iKTZ2q3IiSEDqZ5Nw1vdoGnQCqF-8DAUJRaVwR9obqqTxhMy \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-H 'Cache-Control: no-cache' \
-H 'X-Api-Key: <API_KEY>'

它返回记录数。

{
    "count": 26
}

分页 pagination

默认情况下,一个列表中加载25个资源。

_lineCount ​参数允许您限制响应中列出的资源数。 然后,可以使用​ next ​节点显示下一个结果。

NOTE
始终使用​ next ​节点中返回的URL值执行分页请求。
已计算​**_lineStart**​请求,必须始终在​ next ​节点中返回的URL中使用。

示例请求

用于显示配置文件资源1条记录的示例GET请求。

-X GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/profile?_lineCount=1 \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-H 'Cache-Control: no-cache' \
-H 'X-Api-Key: <API_KEY>'

响应请求,使用​ next ​节点执行分页。

{
    "content": [
        {
            "PKey": "<PKEY>",
            "firstName": "John",
            "lastName":"Doe",
            "birthDate": "1980-10-24",
            ...
        }
    ],
    "next": {
        "href": "https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/profile/email?_lineCount=10&_
        lineStart=@Qy2MRJCS67PFf8soTf4BzF7BXsq1Gbkp_e5lLj1TbE7HJKqc"
    }
    ...
}

默认情况下,在与具有大量数据的表交互时,next ​节点不可用。 若要执行分页,必须将​ _forcePagination=true ​参数添加到调用URL中。

-X GET https://mc.adobe.io/<ORGANIZATION>/campaign/profileAndServices/profile?_forcePagination=true \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-H 'Cache-Control: no-cache' \
-H 'X-Api-Key: <API_KEY>'
NOTE
在Campaign Standard XtkBigTableThreshold ​选项中定义了表大于此值的记录数。 默认值为100,000条记录。
recommendation-more-help
35662671-8e3d-4f04-a092-029a056c566b