Content resource (Shop API 19.1)

Summary

Http Method Resource Description
GET /content/({id},...,{id}) To access multiple content asset, you construct a URL using the template shown below. This template requires you to specify one or many content asset id. In response, the server returns a result set of corresponding content asset documents. Only content assets, which are marked as online are returned. An assignment to a folder is not necessary.
GET /content/{id} To access a content asset, you construct a URL using the template shown below. This template requires you to specify a content asset id. In response, the server returns a corresponding content asset document. Only content assets, which are marked as online are returned. An assignment to a folder is not necessary.

Get multiple content

To access multiple content asset, you construct a URL using the template shown below. This template requires you to specify one or many content asset id. In response, the server returns a result set of corresponding content asset documents. Only content assets, which are marked as online are returned. An assignment to a folder is not necessary.

Url

GET http://hostname:port/dw/shop/v19_1/content/({id},...,{id})?locale={String}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT token.
None No authentication.

Response Document

ContentResult

Path Parameters

Parameter Type Description Constraints
ids [String] The ids of the requested content assets maxItems=50, maxLength=256

Query Parameters

Parameter Type Description Constraints
locale String The locale context  

Customization

This Resource supports server-side customization.

Extension Point Method Detail
dw.ocapi.shop.content.beforeGET

beforeGET (contentId : String ) : Status

The function is called before the request will be processed.

Parameters:
contentId - the id of the content assert
Returns:
a non-null Status ends the hook execution
dw.ocapi.shop.content.modifyGETResponse

modifyGETResponse (scriptContent : Content , doc : Content ) : Status

The function is called after the request has been processed.

Parameters:
scriptContent - an instance of dw.content.Content
doc - the document
Returns:
a non-null Status ends the hook execution

Sample

REQUEST:
GET /dw/shop/v19_1/content/(about-us,terms) HTTP/1.1
Host: example.com
Accept: application/json

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=900,must-revalidate
Content-Length: 13120
{
  "_v":"19.1",
  "_type":"content_result",
  "count":2,
  "total":2,
  "data":
  [
    {
      "description" : "It all started with a series of observations ...",
      "id" : "about-us",
      "name" : "About Us",
      "c_body" : "<h1>About Us</h1><h2>It all started with a series of observations ...",
      "c_customCSSFile" : "http://example.com/on/demandware.static/Sites-SiteGenesis-Site/Sites-SiteGenesis-Library/default/v1365077029384/css/aboutus.css"
    },
    {
      "description" : "These terms of use set forth the basis on which you are permitted to access and use this website, example.com",
      "id" : "terms",
      "name" : "Terms & Conditions of Sale",
      "c_body" : "<h1>Terms & Conditions of Sale</h1><p>ATTENTION: These terms of use set forth the basis on which you are permitted ..."
    }
  ]
}

Get content

To access a content asset, you construct a URL using the template shown below. This template requires you to specify a content asset id. In response, the server returns a corresponding content asset document. Only content assets, which are marked as online are returned. An assignment to a folder is not necessary.

Url

GET http://hostname:port/dw/shop/v19_1/content/{id}?locale={String}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT token.
None No authentication.

Response Document

Content

Path Parameters

Parameter Type Description Constraints
id String The id of the requested content asset. maxLength=256

Query Parameters

Parameter Type Description Constraints
locale String The locale context.  

Customization

This Resource supports server-side customization.

Extension Point Method Detail
dw.ocapi.shop.content.beforeGET

beforeGET (contentId : String ) : Status

The function is called before the request will be processed.

Parameters:
contentId - the id of the content assert
Returns:
a non-null Status ends the hook execution
dw.ocapi.shop.content.modifyGETResponse

modifyGETResponse (scriptContent : Content , doc : Content ) : Status

The function is called after the request has been processed.

Parameters:
scriptContent - an instance of dw.content.Content
doc - the document
Returns:
a non-null Status ends the hook execution

Sample

REQUEST:
GET /dw/shop/v19_1/content/about-us HTTP/1.1
Host: example.com
Accept: application/json

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=900,must-revalidate
Content-Length: 2883

{
  "_v" : "19.1",
  "_type":"content",
  "description" : "It all started with a series of observations...",
  "id" : "about-us",
  "name" : "About Us",
  "c_body" : "<h1>About Us</h1><h2>It all started with a series of observations ...",
  "c_customCSSFile" : "http://example.com/on/demandware.static/Sites-SiteGenesis-Site/Sites-SiteGenesis-Library/default/v1365077029384/css/aboutus.css"
}