Preview the results from the recommendation by apiName.

post

/content/preview/api/v1.1/personalization/recommendationResults/{apiName}

Preview the results of the recommendation specified by the apiName. This endpoint is used to run and preview the recommendation by specifying values for the audience attributes defined in the recommendation.

Audience attributes must be specified as part of the query parameters as name value pairs prepended with the keyword attribute as follows: attribute.\.\=\

Example: ?attribute.custom.myAttribute1=value1&attribute.custom.myAttribute2=value2



Where multivalued audience attributes are allowed, they should be provided in the query by repeating the name value pairs.

Example: ?attribute.custom.myMultiValue=value1&attribute.custom.myMultiValue=value2 etc.

Note: Taxonomy related information in the response will not be shown until the taxonomy is published to the specified channel although filtering categorized assets using rules with promoted version of taxonomies and it's categories is allowed

Request

Supported Media Types
Path Parameters
  • API name of the recommendation. Any special characters present must be encoded.
Query Parameters
  • Collection Format: multi
    List of audience attributes. Any special characters present must be encoded.The audience attributes should be prefixed with the keyword attribute:

    attribute.\.\=\

    Example: ?attribute.custom.myAttribute1=value1&attribute.custom.myAttribute2=value2

  • Channel token of the targeted channel. A channel token must be provided as either a query parameter or a request header.
  • The fields parameter is used to control the returned fields and values in the queried item. This parameter accepts a comma-separated list of field names or all. All the user-defined field names should be provided with prefix fields and followed by a period (.). These fields will be returned for each queried item. As all the field names are case-sensitive, users must provide the correct field names in the search query. When fields is specified as all (case-insensitive), in case of a type-specific query, all the standard fields, and user-defined fields except largetext, json, location datatype are returned for each queried item, whereas in case of a query across all types, only all standard fields are returned. The standard fields id and type are always returned in the response and cannot be filtered out. This parameter is optional in the query and by default query result shows only id, name, description, and type in the response. Any incorrect or invalid field name given in the query will be ignored.

    In the context of a brace style cross-type query, type specific fields may be specified using syntax name,{typename1:fields.userdefinedfieldname1,fields.userdefinedfieldname2},{typename2:fields.userdefinedfieldname1}.In the preceding example, all items of type typename1 will have fields - name, userdefinedfieldname1 and userdefinedfieldname2, while all items of type typename2 will have fields - name, userdefinedfieldname1. If the cross-type query does not resolve to types referenced in the typed fields clause(s), an error will be thrown. Example: ?q=(type eq "LocationType")&fields=fields.state,fields.country,updatedDate
    This returns id, type, state, country, updatedDate in the search results for a LocationType with state and country fields.
    Example: ?q=(type eq "LocationType")&fields=all
    This will return all standard fields and all user-defined fields except largetext, json, location data types
    Example: ?fields=all
    This will return only standard fields (id, type, typeCategory, name, description, slug, language, createdDate, updatedDate, taxonomies, renditions) since Type is not used in the search query (acts as a Global query)
    Default Value: name,description
  • This parameter accepts a non negative integer and is used to control the size of the result. The maximum value allowed for limit is 500.
    Default Value: 100
  • Start index of response rows.
    Default Value: 0
  • Accepts a boolean value. This value is always set to true and displays the total results in the response.
    Default Value: true
Body ()
Array of audience attribute name value pairs. These will be used as input to the recommendation.

Attribute entries can be provided as a single value:
"\.\" : "\"
or as an array in the case of multi value attributes:
"\.\" : ["\", "\", ... ]

NOTE: Audience attributes specified in the query will override audience attributes specified in the body.
For preview of recommendations, only valid value for asset state is PREVIEW
Root Schema : RecommendationTest
Type: object
Recommendation Test
Show Source
  • Allowed Values: [ "PUBLISHED", "ALL", "PREVIEW" ]
    A Enum that is used to determine if only published assets should be returned in the testing of the recommendation. Valida values are ALL and PUBLISHED. Default value is ALLe.
  • audienceAttributes
    Additional Properties Allowed: additionalProperties
    Array of audience attributes to be used in testing the recommendation. Each attribute can be proprovided as a single value:
    "\.\" : "\"
    or as an array for multi value attributes:
    "\.\" : ["\", "\" ... ]
Nested Schema : audienceAttributes
Type: object
Additional Properties Allowed
Show Source
Array of audience attributes to be used in testing the recommendation. Each attribute can be proprovided as a single value:
"\.\" : "\"
or as an array for multi value attributes:
"\.\" : ["\", "\" ... ]
Nested Schema : additionalProperties
Type: array
Show Source
Back to Top

Response

Supported Media Types

201 Response

Successfully created
Body ()
Root Schema : CollectionProperties
Type: object
CollectionProperties.
Show Source
Nested Schema : aggregationResults
Type: array
Aggregation results.
Show Source
Nested Schema : items
Type: array
Singular resources contained in the collection.
Show Source
Nested Schema : pinned
Type: array
Pinned items. Shows items pinned at the top of search list
Show Source
Nested Schema : properties
Type: object
Additional Properties Allowed
Show Source
additional collection properties.
Nested Schema : AggregationResult
Type: object
Show Source
Nested Schema : items
Type: object
Nested Schema : additionalProperties
Type: object

400 Response

Bad Request. The server is unable to process the request on the client side due to malformed syntax, invalid data or message framing.

403 Response

Forbidden. Client is not authorized to perform this request.

500 Response

Internal server error. An unexpected error condition encountered in the system.
Back to Top

Examples

Example 1:

The following example shows how to preview a recommendation by apiName by submission of a POST request on the REST resource using cURL:

curl -X POST -H 'Accept: application/json' 'https://host:port/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1279349095962005?attribute.custom.attribute-ts-1=Single value&channelToken=b1230e5b0e7f4e998d586391ca1647da&fields=all'

This previews recommendation with apiName: Recommendation1279349095962005, channelToken: b1230e5b0e7f4e998d586391ca1647da. Audience attribute is provided in the url which will match the rules.

Request Payload

{
        "audienceAttributes": {
        },
        "assetState": "PREVIEW"
}

Response Body

{
        "hasMore": false,
        "offset": 0,
        "count": 2,
        "limit": 2,
        "totalResults": 2,
        "items": [
          {
            "description": "Complex item - 278890853097008",
            "language": "en-US",
            "updatedDate": {
              "value": "2021-10-28T11:18:29.112Z",
              "timezone": "UTC"
            },
            "mimeType": "contentItem",
            "type": "278799601349002-testRecommendation-complexType",
            "typeCategory": "ContentType",
            "createdDate": {
              "value": "2021-10-28T11:18:19.541Z",
              "timezone": "UTC"
            },
            "taxonomies": {
              "items": []
            },
            "name": "contentItem3ComplexType-278890853059007",
            "renditions": {
              "items": []
            },
            "links": [
              {
                "href": "https://<hostname>/content/preview/api/v1.1/items/CORE05B1B553E20B46DC8A1ACE333958BBB1?channelToken=b1230e5b0e7f4e998d586391ca1647da",
                "rel": "self",
                "method": "GET",
                "mediaType": "application/json"
              }
            ],
            "id": "CORE05B1B553E20B46DC8A1ACE333958BBB1",
            "fileGroup": "contentItem",
            "fields": {
              "Text_single_1": "Single value",
              "Number_1": 111,
              "Text_multi_1": [
                "Aaa bbb ccc",
                "Ddd eee fff"
              ],
              "Decimal_1": 1.11,
              "Boolean_1": true
            },
            "slug": "3000000010216-contentitem3complextype-278890853059007"
          },
          {
            "description": "Complex item - 278862344909006",
            "language": "en-US",
            "updatedDate": {
              "value": "2021-10-28T11:18:57.169Z",
              "timezone": "UTC"
            },
            "mimeType": "contentItem",
            "type": "278799601349002-testRecommendation-complexType",
            "typeCategory": "ContentType",
            "createdDate": {
              "value": "2021-10-28T11:18:19.101Z",
              "timezone": "UTC"
            },
            "taxonomies": {
              "items": []
            },
            "name": "contentItem2ComplexTypePub-278862344860005",
            "renditions": {
              "items": []
            },
            "links": [
              {
                "href": "https://<hostname>/content/preview/api/v1.1/items/CORE84C77C63C8DF4A80A26599B1B0FB964F?channelToken=b1230e5b0e7f4e998d586391ca1647da",
                "rel": "self",
                "method": "GET",
                "mediaType": "application/json"
              }
            ],
            "id": "CORE84C77C63C8DF4A80A26599B1B0FB964F",
            "fileGroup": "contentItem",
            "fields": {
              "Text_single_1": "Single value",
              "Number_1": 111,
              "Text_multi_1": [
                "Aaa bbb ccc",
                "Ddd eee fff"
              ],
              "Decimal_1": 1.11,
              "Boolean_1": true
            },
            "slug": "3000000010215-contentitem2complextypepub-278862344860005"
          }
        ],
        "links": [
          {
            "href": "https://<hostname>/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1279349095962005?attribute.custom.attribute-ts-1=Single value&channelToken=b1230e5b0e7f4e998d586391ca1647da&fields=all",
            "rel": "self",
            "method": "POST",
            "mediaType": "application/json"
          },
          {
            "href": "https://<hostname>/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1279349095962005?attribute.custom.attribute-ts-1=Single value&channelToken=b1230e5b0e7f4e998d586391ca1647da&fields=all",
            "rel": "canonical",
            "method": "POST",
            "mediaType": "application/json"
          },
          {
            "href": "https://<hostname>/content/preview/api/v1.1/metadata-catalog/personalization/recommendationResults/Recommendation1279349095962005?channelToken=b1230e5b0e7f4e998d586391ca1647da",
            "rel": "describedby",
            "method": "GET",
            "mediaType": "application/schema+json"
          },
          {
            "href": "https://<hostname>/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1279349095962005?attribute.custom.attribute-ts-1=Single value&channelToken=b1230e5b0e7f4e998d586391ca1647da&fields=all&offset=0",
            "rel": "first",
            "method": "POST",
            "mediaType": "application/json"
          },
          {
            "href": "https://<hostname>/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1279349095962005?attribute.custom.attribute-ts-1=Single value&channelToken=b1230e5b0e7f4e998d586391ca1647da&fields=all&offset=0",
            "rel": "last",
            "method": "POST",
            "mediaType": "application/json"
          }
        ]
      }

Example 2:

curl -X POST -H 'Accept: application/json' 'https://host:port/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1279349095962005?attribute.custom.attribute-ts-1=WillNeverMatch&channelToken=b1230e5b0e7f4e998d586391ca1647da&fields=all'

This previews recommendation with apiName: Recommendation1279349095962005, channelToken: b1230e5b0e7f4e998d586391ca1647da. Audience attribute is provided in the url and since no rules match, defaults are returned.

Request Payload

{
        "audienceAttributes": {
        },
        "assetState": "PREVIEW"
    },

Response Body

{
        "hasMore": false,
        "offset": 0,
        "count": 2,
        "limit": 2,
        "totalResults": 2,
        "items": [
          {
            "description": "Complex item - 278857744875004",
            "language": "en-US",
            "updatedDate": {
              "value": "2021-10-28T11:19:09.889Z",
              "timezone": "UTC"
            },
            "mimeType": "contentItem",
            "type": "278799601349002-testRecommendation-complexType",
            "typeCategory": "ContentType",
            "createdDate": {
              "value": "2021-10-28T11:18:16.312Z",
              "timezone": "UTC"
            },
            "taxonomies": {
              "items": []
            },
            "name": "contentItem1ComplexTypePub-278857744819003",
            "renditions": {
              "items": []
            },
            "links": [
              {
                "href": "https://<hostname>/content/preview/api/v1.1/items/COREBE5441D25AF4449CA58430AC33587B74?channelToken=b1230e5b0e7f4e998d586391ca1647da",
                "rel": "self",
                "method": "GET",
                "mediaType": "application/json"
              }
            ],
            "id": "COREBE5441D25AF4449CA58430AC33587B74",
            "fileGroup": "contentItem",
            "fields": {
              "Text_single_1": "ZZZZZZ",
              "Number_1": 111,
              "Text_multi_1": [
                "Aaa bbb ccc",
                "Ddd eee fff"
              ],
              "Decimal_1": 1.11,
              "Boolean_1": true
            },
            "slug": "3000000010214-contentitem1complextypepub-278857744819003"
          },
          {
            "description": "Complex item - 278897517017002",
            "language": "en-US",
            "updatedDate": {
              "value": "2021-10-28T11:18:34.754Z",
              "timezone": "UTC"
            },
            "mimeType": "contentItem",
            "type": "278799601349002-testRecommendation-complexType",
            "typeCategory": "ContentType",
            "createdDate": {
              "value": "2021-10-28T11:18:20.214Z",
              "timezone": "UTC"
            },
            "taxonomies": {
              "items": []
            },
            "name": "contentItem5ComplexTypePub-278897516976001",
            "renditions": {
              "items": []
            },
            "links": [
              {
                "href": "https://<hostname>/content/preview/api/v1.1/items/CORE3E0B1C2E479B43E3A42A0955ED5A79DC?channelToken=b1230e5b0e7f4e998d586391ca1647da",
                "rel": "self",
                "method": "GET",
                "mediaType": "application/json"
              }
            ],
            "id": "CORE3E0B1C2E479B43E3A42A0955ED5A79DC",
            "fileGroup": "contentItem",
            "fields": {
              "Text_single_1": "Single value",
              "Number_1": 111,
              "Text_multi_1": [
                "Aaa bbb ccc",
                "Ddd eee fff"
              ],
              "Decimal_1": 1.11,
              "Boolean_1": true
            },
            "slug": "3000000010218-contentitem5complextypepub-278897516976001"
          }
        ],
        "links": [
          {
            "href": "https://<hostname>/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1279349095962005?attribute.custom.attribute-ts-1=WillNeverMatch&channelToken=b1230e5b0e7f4e998d586391ca1647da&fields=all",
            "rel": "self",
            "method": "POST",
            "mediaType": "application/json"
          },
          {
            "href": "https://<hostname>/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1279349095962005?attribute.custom.attribute-ts-1=WillNeverMatch&channelToken=b1230e5b0e7f4e998d586391ca1647da&fields=all",
            "rel": "canonical",
            "method": "POST",
            "mediaType": "application/json"
          },
          {
            "href": "https://<hostname>/content/preview/api/v1.1/metadata-catalog/personalization/recommendationResults/Recommendation1279349095962005?channelToken=b1230e5b0e7f4e998d586391ca1647da",
            "rel": "describedby",
            "method": "GET",
            "mediaType": "application/schema+json"
          },
          {
            "href": "https://<hostname>/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1279349095962005?attribute.custom.attribute-ts-1=WillNeverMatch&channelToken=b1230e5b0e7f4e998d586391ca1647da&fields=all&offset=0",
            "rel": "first",
            "method": "POST",
            "mediaType": "application/json"
          },
          {
            "href": "https://<hostname>/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1279349095962005?attribute.custom.attribute-ts-1=WillNeverMatch&channelToken=b1230e5b0e7f4e998d586391ca1647da&fields=all&offset=0",
            "rel": "last",
            "method": "POST",
            "mediaType": "application/json"
          }
        ]
      }

Example 3:

curl -X POST -H 'Accept: application/json' 'https://host:port/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1280114148212007?fields=all&channelToken=b1230e5b0e7f4e998d586391ca1647da'

This previews recommendation with apiName: Recommendation1280114148212007, channelToken: b1230e5b0e7f4e998d586391ca1647da. Audience attributes are provided in the body of the request which will match the rules.

Request Payload

{
        "audienceAttributes": {
          "custom.attribute-bool-1": [
            "Another single onezzz",
            "And this alsozzz"
          ],
          "custom.attribute-ts-1": [
            "Another single one",
            "And this also"
          ]
        },
        "assetState": "PREVIEW"
      },

Response Body

{
        "hasMore": false,
        "offset": 0,
        "count": 2,
        "limit": 2,
        "totalResults": 2,
        "items": [
          {
            "description": "Complex item - 278890853097008",
            "language": "en-US",
            "updatedDate": {
              "value": "2021-10-28T11:19:57.100Z",
              "timezone": "UTC"
            },
            "mimeType": "contentItem",
            "type": "278799601349002-testRecommendation-complexType",
            "typeCategory": "ContentType",
            "createdDate": {
              "value": "2021-10-28T11:18:19.541Z",
              "timezone": "UTC"
            },
            "taxonomies": {
              "items": []
            },
            "name": "contentItem3ComplexType-278890853059007",
            "renditions": {
              "items": []
            },
            "links": [
              {
                "href": "https://<hostname>/content/preview/api/v1.1/items/CORE05B1B553E20B46DC8A1ACE333958BBB1?channelToken=b1230e5b0e7f4e998d586391ca1647da",
                "rel": "self",
                "method": "GET",
                "mediaType": "application/json"
              }
            ],
            "id": "CORE05B1B553E20B46DC8A1ACE333958BBB1",
            "fileGroup": "contentItem",
            "fields": {
              "Text_single_1": "Another single one",
              "Number_1": 222,
              "Text_multi_1": [
                "Ggg hhh iii",
                "Jjj kkk lll"
              ],
              "Decimal_1": 2.22,
              "Boolean_1": false
            },
            "slug": "3000000010216-contentitem3complextype-278890853059007"
          },
          {
            "description": "Complex item - 278894031582000",
            "language": "en-US",
            "updatedDate": {
              "value": "2021-10-28T11:19:57.750Z",
              "timezone": "UTC"
            },
            "mimeType": "contentItem",
            "type": "278799601349002-testRecommendation-complexType",
            "typeCategory": "ContentType",
            "createdDate": {
              "value": "2021-10-28T11:18:19.885Z",
              "timezone": "UTC"
            },
            "taxonomies": {
              "items": []
            },
            "name": "contentItem4ComplexTypePub-278894031536009",
            "renditions": {
              "items": []
            },
            "links": [
              {
                "href": "https://<hostname>/content/preview/api/v1.1/items/CORE9272086F9EC046F5879E6343F2933D15?channelToken=b1230e5b0e7f4e998d586391ca1647da",
                "rel": "self",
                "method": "GET",
                "mediaType": "application/json"
              }
            ],
            "id": "CORE9272086F9EC046F5879E6343F2933D15",
            "fileGroup": "contentItem",
            "fields": {
              "Text_single_1": "And this also",
              "Number_1": 333,
              "Text_multi_1": [
                "Mmm nnn ooo",
                "Ppp qqq rrr"
              ],
              "Decimal_1": 3.33,
              "Boolean_1": false
            },
            "slug": "3000000010217-contentitem4complextypepub-278894031536009"
          }
        ],
        "links": [
          {
            "href": "https://<hostname>/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1280114148212007?fields=all&channelToken=b1230e5b0e7f4e998d586391ca1647da",
            "rel": "self",
            "method": "POST",
            "mediaType": "application/json"
          },
          {
            "href": "https://<hostname>/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1280114148212007?fields=all&channelToken=b1230e5b0e7f4e998d586391ca1647da",
            "rel": "canonical",
            "method": "POST",
            "mediaType": "application/json"
          },
          {
            "href": "https://<hostname>/content/preview/api/v1.1/metadata-catalog/personalization/recommendationResults/Recommendation1280114148212007?channelToken=b1230e5b0e7f4e998d586391ca1647da",
            "rel": "describedby",
            "method": "GET",
            "mediaType": "application/schema+json"
          },
          {
            "href": "https://<hostname>/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1280114148212007?fields=all&offset=0&channelToken=b1230e5b0e7f4e998d586391ca1647da",
            "rel": "first",
            "method": "POST",
            "mediaType": "application/json"
          },
          {
            "href": "https://<hostname>/content/preview/api/v1.1/personalization/recommendationResults/Recommendation1280114148212007?fields=all&offset=0&channelToken=b1230e5b0e7f4e998d586391ca1647da",
            "rel": "last",
            "method": "POST",
            "mediaType": "application/json"
          }
        ]
      }
    }
  ]
}
Back to Top