Folders resource (Shop API 23.2)

Summary

Http Method Resource Description
GET /folders/({id},...,{id}) To access one or more content folder, you construct a URL using the template shown below. This template requires you to specify one or more content folder ids and a subfolder level. In response, the server returns a result set of corresponding content folder documents. Only content folder, which are marked as online are returned.
GET /folders/{id} To access a content folder, you construct a URL using the template shown below. This template requires you to specify a content folder id and a subfolder level. In response, the server returns a corresponding content folder document. Only content folder, which are marked as online are returned.

Get multiple content folders

To access one or more content folder, you construct a URL using the template shown below. This template requires you to specify one or more content folder ids and a subfolder level. In response, the server returns a result set of corresponding content folder documents. Only content folder, which are marked as online are returned.

Url

GET http://hostname:port/dw/shop/v23_2/folders/({id},...,{id})?levels={Integer}&locale={String}

Formats

json, xml

Authentication

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

Response Document

ContentFolderResult

Path Parameters

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

Query Parameters

Parameter Type Description Constraints
levels Integer Specifies how many levels of nested subfolders you want the server to return. The default value is 1. Valid values are 0, 1, or 2. maxIntegerValue=2, minIntegerValue=0
locale String The locale context.  

Customization

This Resource supports server-side customization.

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

beforeGET (id : String ) : Status

The function is called before the request will be processed.

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

modifyGETResponse (scriptFolder : Folder , doc : ContentFolder ) : Status

The function is called after the request has been processed.

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

Sample

REQUEST:
GET /dw/shop/v23_2/folders/(our-story,our-team)?levels=0 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
{
  "_v" : "23.2",
  "_type":"content_folder_result",
  "count":2,
  "total":2,
  "data":
  [
    {
      "id" : "our-story",
      "name" : "Our Story",
      "parent_folder_id" : "about-us"
    },
    {
      "id" : "our-team",
      "name" : "Our Team",
      "parent_folder_id" : "about-us"
    }
  ]
}

Get content folder

To access a content folder, you construct a URL using the template shown below. This template requires you to specify a content folder id and a subfolder level. In response, the server returns a corresponding content folder document. Only content folder, which are marked as online are returned.

Url

GET http://hostname:port/dw/shop/v23_2/folders/{id}?levels={Integer}&locale={String}

Formats

json, xml

Authentication

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

Response Document

ContentFolder

Path Parameters

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

Query Parameters

Parameter Type Description Constraints
levels Integer Specifies how many levels of nested subfolders you want the server to return. The default value is 1. Valid values are 0, 1, or 2. maxIntegerValue=2, minIntegerValue=0
locale String The locale context.  

Customization

This Resource supports server-side customization.

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

beforeGET (id : String ) : Status

The function is called before the request will be processed.

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

modifyGETResponse (scriptFolder : Folder , doc : ContentFolder ) : Status

The function is called after the request has been processed.

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

Sample

REQUEST:
GET /dw/shop/v23_2/folders/about-us?levels=1 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: 741

{
  "_v" : "23.2",
  "_type":"content_folder",
  "folders" : 
  [ 
    {
      "id" : "our-story",
      "name" : "Our Story",
      "parent_folder_id" : "about-us"
    }, {
      "id" : "our-team",
      "name" : "Our Team",
      "parent_folder_id" : "about-us"
    }, {
      "id" : "as-seen-in",
      "name" : "As Seen In",
      "parent_folder_id" : "about-us"
    }, {
      "id" : "contact-us-new",
      "name" : "Contact Us",
      "parent_folder_id" : "about-us"
    }, {
      "id" : "employment",
      "name" : "Join Us",
      "parent_folder_id" : "about-us"
    }
  ],
  "id" : "about-us",
  "name" : "About Salesforce Commerce Cloud",
  "parent_folder_id" : "root",
  "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.