Class RemoteInclude

The class represents a remote include value that can be assigned to JSON Object properties.

Important notes:

  • Authentication and authorization checks are performed only for the top level request, but NOT for remote include requests.
  • The RestResponseMgrmethod createScapiRemoteInclude()allows only SCAPI URLs.
  • The RestResponseMgrmethod createStorefrontControllerRemoteInclude()allows only Controller URLs.
  • Correct rendering of RemoteInclude-containing objects is only performed when processed by dw.system.RESTSuccessResponse.render()method. Please check the provided examples.

Example 1. Specify remote include properties.

1function specifyRemoteIncludeProperties() {
2   var includeValue0 = dw.system.RESTResponseMgr.createScapiRemoteInclude("custom", "sample", "v1", "resource/path/0", dw.web.URLParameter("siteId", "TestWapi"));
3   var includeValue1 = dw.system.RESTResponseMgr.createScapiRemoteInclude("custom", "sample", "v1", "resource/path/1", dw.web.URLParameter("siteId", "TestWapi"));
4   var greeting = { "hello": "world", "includeProperty0": includeValue0, "includeProperty1": includeValue1 };
5
6   dw.system.RESTResponseMgr.createSuccess(greeting).render();
7}

Example 2. Specify array of remote include properties.

1function specifyArrayOfRemoteIncludes() {
2  var includeValue0 = dw.system.RESTResponseMgr.createScapiRemoteInclude("custom", "sample", "v1", "resource/path/0", dw.web.URLParameter("siteId", "TestWapi"));
3  var includeValue1 = dw.system.RESTResponseMgr.createScapiRemoteInclude("custom", "sample", "v1", "resource/path/1", dw.web.URLParameter("siteId", "TestWapi"));
4  var greeting = { "hello": "world", "includeArray": [includeValue0, includeValue1] };
5
6  dw.system.RESTResponseMgr.createSuccess(greeting).render();
7}

Example 3. Storefront controller remote include.

1function storefrontRemoteInclude()
2{
3    let remoteInclude = dw.system.RESTResponseMgr.createStorefrontControllerRemoteInclude(new URLAction("Category-Show", "Sites-MyShop-Site", dw.web.URLParameter("cid", "root")));
4    let json = {
5        status: "JSONOK",
6        include: remoteInclude
7    };
8    dw.system.RESTResponseMgr.createSuccess(json).render();
9}

Error handling:

SCAPI:

  • In case of 404 response received on included resource, an empty JSON object ’{}’ will be supplied in final JSON.
  • In case of 201..299, 3xx, 4xx (excluding 404), 5xx response from included resource, final response status will be 500 ‘Internal Server Error’

Controllers:

  • In case of any non 200 response from the included resource an empty string will be included.
  • Note: In case your response format is JSON be aware that this can result in invalid JSON.

Property Summary 

PropertyDescription
url: String (read-only)Returns the URL string value specified for the current instance.

Constructor Summary 

This class does not have a constructor, so you cannot create it directly.

Method Summary 

MethodDescription
getUrl()Returns the URL string value specified for the current instance.
toString()Returns the URL string value specified for the current instance, same as getUrl().
valueOf()Returns the URL string value specified for the current instance, same as getUrl().

Methods inherited from class Object 

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

Property Details 

url 

url: String (read-only)

Returns the URL string value specified for the current instance.


Method Details 

getUrl() 

getUrl(): String

Returns the URL string value specified for the current instance.


toString() 

toString(): String

Returns the URL string value specified for the current instance, same as getUrl().


valueOf() 

valueOf(): Object

Returns the URL string value specified for the current instance, same as getUrl().