Content resource (Shop API 23.2)

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/v23_2/content/({id},...,{id})?locale={String}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT.
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/v23_2/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" : "23.2",
  "_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/v23_2/content/{id}?locale={String}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT.
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/v23_2/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" : "23.2",
  "_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"
}
X OCAPI versions 15.x and 16.x will be retired on March 31, 2021. For dates and more information, see the OCAPI versioning and deprecation policy and this Knowledge Article.