CampaignSearch resource (Data API 19.1)

Summary

Http Method Resource Description
POST /sites/{site_id}/campaign_search

Searches for campaigns.

The Campaign Search document contains a search object that allows filtering on various attributes.

The query attribute specifies a complex query that can be used to narrow down the search. These are the list of searchable attributes:

  • campaign_id - String
  • description - String
  • enabled - Boolean
  • coupon_id* - String
  • customer_group* - String
  • source_code* - String
  • start_date - Date
  • end_date - Date
  • last_modified - Date

These fields can only be used in Queries as conjunctions (using AND). If the field is used in a disjunction (OR) an exception will be thrown.

Note that only searchable attributes (excluding the ones marked with above with an asterisk) can be used in sorting Additionally start_date, end_date and last_modified cannot be used in sorting.

Search Campaigns

Searches for campaigns.

The Campaign Search document contains a search object that allows filtering on various attributes.

The query attribute specifies a complex query that can be used to narrow down the search. These are the list of searchable attributes:

These fields can only be used in Queries as conjunctions (using AND). If the field is used in a disjunction (OR) an exception will be thrown.

Note that only searchable attributes (excluding the ones marked with above with an asterisk) can be used in sorting Additionally start_date, end_date and last_modified cannot be used in sorting.

Url

POST https://hostname:port/dw/data/v19_1/sites/{site_id}/campaign_search

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Request Document

SearchRequest

Response Document

CampaignSearchResult

Path Parameters

Parameter Type Description Constraints
site_id String The site context. minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 MalformedSearchParameterException   Thrown if the query is ill-formed.

Sample

REQUEST:
POST /s/-/dw/data/v19_1/sites/site-one/campaign_search HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
Accept: application/json
{
    "count" : 4,
    "query" : {
        "text_query": {
            "fields": ["id", "description"],
            "search_phrase": "campaign"
        }
    },
    "select" : "(**)",
    "start" : 2
}

RESPONSE:
HTTP/1.1 200 OK
Content-Length: 67
Content-Type: application/json; charset=UTF-8
{
  "_v" : "19.1",
   "_type" : "campaign_search_result",
  "count" : 4,
   "hits" : [
      {
         "campaign_id" : "disabled-campaign",
         "_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
         "enabled" : false,
         "link" : "https://example.com/s/-/dw/data/v19_1/sites/SiteGenesis/campaigns/disabled-campaign"
      },
      {
         "campaign_id" : "test-campaign",
         "_resource_state" : "847f9c3c5867f641470b3046aeec31f07757991b792d722e10079926f7a289fb",
         "coupons" : [
            "couponOne"
         ],
         "customer_groups" : [
            "Everyone"
         ],
         "description" : "Test Campaign",
         "enabled" : true,
         "link" : "https://example.com/s/-/dw/data/v19_1/sites/SiteGenesis/campaigns/test-campaign"
      },
      {
         "campaign_id" : "test-campaign-continuous",
         "_resource_state" : "t9ccde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73b8h6",
         "enabled" : true,
         "link" : "https://example.com/s/-/dw/data/v19_1/sites/SiteGenesis/campaigns/test-campaign-continuous"
      },
      {
         "campaign_id" : "test-campaign-end-continuous",
         "_resource_state" : "045f07bb655171dc37d8eb8bf4b0db7ac1fb3a160002eb96fbe6e2f95aa4b6cc",
         "enabled" : true,
         "link" : "https://example.com/s/-/dw/data/v19_1/sites/SiteGenesis/campaigns/test-campaign-end-continuous"
      }
   ],
  "query" : { "text_query": { "fields": ["id", "description"], "search_phrase": "campaign" } },
  "select": "**",
  "start" : 2,
  "total" : 8
}

# in case of failure:
POST /dw/data/v19_1/sites/site-one/campaign_search HTTP/1.1
Host: example.com
Accept: application/json
{ "my-unknown-property" : "abcdef" }

RESPONSE:
HTTP/1.1 400 Bad Request
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
   "_v" : "19.1",
   "_type":"fault",
   "fault" : {
      "type" : "UnknownPropertyException",
      "message" : "An error occurred while decoding the request. There is an unknown property ''my-unknown-property' in document 'campaign_search_request'."
   }
}