Class Request
Represents a request in Commerce Cloud Digital. Each pipeline dictionary contains a CurrentRequest object, which is of type dw.system.Request. Most requests are HTTP requests, so you can use this object to get information about the HTTP request, such as the HTTP headers. You can also get a list of cookies, if any, associated with the request. If the request is issued from a job, the request is not an HTTP request, so HTTP-related methods return null.
| Property | Description |
|---|---|
SCAPI: Boolean (read-only) | Returns whether the request originated in SCAPI. |
SCAPIPathParameters: Map (read-only) | Returns a map containing all path parameters of current SCAPI request in the following way:
|
SCAPIPathPattern: String (read-only) | Returns the SCAPI path pattern in the following way:
|
clientId: String (read-only) | Returns the client id of the current SCAPI or OCAPI request. |
custom: CustomAttributes (read-only) | Returns all of the custom attributes associated with the request. |
| geolocation: Geolocation | Returns the physical location for the current request, if available. |
httpCookies: Cookies (read-only) | Returns the Cookies object, which can be used to read cookies sent by the client. |
httpHeaders: Map (read-only) | Returns a Map containing all HTTP header values. |
httpHost: String (read-only) | Returns the host name or null if there is no host name. |
httpLocale: String (read-only) | Returns the locale or null if there is no associated locale. |
httpMethod: String (read-only) | Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. |
httpParameterMap: HttpParameterMap (read-only) | Returns the parameter map that contains the HTTP parameters for the current request. |
httpParameters: Map (read-only) | Returns a Map containing the raw HTTP parameters sent to the server. |
httpPath: String (read-only) | Returns the path. |
httpProtocol: String (read-only) | Returns the HTTP protocol used for this request. |
httpQueryString: String (read-only) | Returns the query string or null if there is no query string. |
httpReferer: String (read-only) | Returns the referer or null if there is no referer. |
httpRemoteAddress: String (read-only) | Returns the remote address or null if no remote address is found. |
(read-only) | Identifies if this request is an HTTP request. |
httpSecure: Boolean (read-only) | Returns whether the HTTP communication is secure, which basically means that the communication happens via https. |
httpURL: URL (read-only) | Returns the complete URL of the request which was received at the server. |
httpUserAgent: String (read-only) | Returns the HTTP user agent or null if there is no user agent. |
includeRequest: Boolean (read-only) | Returns true if the request represents a request for a remote include, false if it is a top-level request. |
| locale: String | Returns the locale of the current request. |
ocapiVersion: String (read-only) | Returns the OCAPI version of the current request. |
pageMetaData: PageMetaData (read-only) | Returns the page meta data that are associated with the current request. |
requestID: String (read-only) | Returns the unique identifier of the current request. |
session: Session (read-only) | Returns the session associated with this request. |
triggeredForm: Form (read-only) | Returns the form that was submitted by the client if the request represents a form submission. |
triggeredFormAction: FormAction (read-only) | Returns the form action that was triggered by the client if the request represents a form submission. |
This class does not have a constructor, so you cannot create it directly.
| Method | Description |
|---|---|
| Adds the specified cookie to the outgoing response. | |
| getClientId() | Returns the client id of the current SCAPI or OCAPI request. |
| getCustom() | Returns all of the custom attributes associated with the request. |
| getGeolocation() | Returns the physical location for the current request, if available. |
| getHttpCookies() | Returns the Cookies object, which can be used to read cookies sent by the client. |
| getHttpHeaders() | Returns a Map containing all HTTP header values. |
| getHttpHost() | Returns the host name or null if there is no host name. |
| getHttpLocale() | Returns the locale or null if there is no associated locale. |
| getHttpMethod() | Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. |
| getHttpParameterMap() | Returns the parameter map that contains the HTTP parameters for the current request. |
| getHttpParameters() | Returns a Map containing the raw HTTP parameters sent to the server. |
| getHttpPath() | Returns the path. |
| getHttpProtocol() | Returns the HTTP protocol used for this request. |
| getHttpQueryString() | Returns the query string or null if there is no query string. |
| getHttpReferer() | Returns the referer or null if there is no referer. |
| getHttpRemoteAddress() | Returns the remote address or null if no remote address is found. |
| getHttpURL() | Returns the complete URL of the request which was received at the server. |
| getHttpUserAgent() | Returns the HTTP user agent or null if there is no user agent. |
| getLocale() | Returns the locale of the current request. |
| getOcapiVersion() | Returns the OCAPI version of the current request. |
| getPageMetaData() | Returns the page meta data that are associated with the current request. |
| getRequestID() | Returns the unique identifier of the current request. |
| getSCAPIPathParameters() | Returns a map containing all path parameters of current SCAPI request in the following way:
|
| getSCAPIPathPattern() | Returns the SCAPI path pattern in the following way:
|
| getSession() | Returns the session associated with this request. |
| getTriggeredForm() | Returns the form that was submitted by the client if the request represents a form submission. |
| getTriggeredFormAction() | Returns the form action that was triggered by the client if the request represents a form submission. |
| Identifies if this request is an HTTP request. | |
| isHttpSecure() | Returns whether the HTTP communication is secure, which basically means that the communication happens via https. |
| isIncludeRequest() | Returns true if the request represents a request for a remote include, false if it is a top-level request. |
| isSCAPI() | Returns whether the request originated in SCAPI. |
| setGeolocation(Geolocation) | Sets the physical location for the current request and remembers the new value for the duration of the user session. |
| setLocale(String) | Sets the given locale for the request. |
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
- SCAPI: Boolean
(read-only) Returns whether the request originated in SCAPI.
- SCAPIPathParameters: Map
(read-only) Returns a map containing all path parameters of current SCAPI request in the following way:
- keys: path parameter names from path pattern
- values: corresponding path parameter values from current request
Returns null if isSCAPI() returns false i.e. if the request is not a SCAPI request.
For example:
- Current request:
/product/shopper-products/v1/organizations/sfcc_org/products/apple-ipod-shuffle - Path pattern:
/product/shopper-products/v1/organizations/{organizationId}/products/{id} - Result: Mapwith 2 key
pairs: organizationId:sfcc_organdid:apple-ipod-shuffle.
- SCAPIPathPattern: String
(read-only) Returns the SCAPI path pattern in the following way:
-
The first three segments
/api-family/api-name/versionwith concrete values. -
The /organizations part with the path parameter name
organizationIdin curly brackets. - The actual resource path additional path parameter names in curly brackets.
Returns null if isSCAPI() returns false i.e. if the request is not a SCAPI request.
For example, in the context of a request to get a single product from shopper-products API, this method would return
/product/shopper-products/v1/organizations/{organizationId}/products/{id}-
The first three segments
- clientId: String
(read-only) Returns the client id of the current SCAPI or OCAPI request. If the request is not a SCAPI request or not an OCAPI request 'null' is returned. For client ids owned by Commerce Cloud Digital an alias is returned.
- custom: CustomAttributes
(read-only) Returns all of the custom attributes associated with the request. The attributes are stored for the life time of the request.
- geolocation: Geolocation
Returns the physical location for the current request, if available. The location is calculated based on the IP address of the request. Note, if the geolocation tracking feature is not enabled, this method always returns null.
- httpCookies: Cookies
(read-only) Returns the Cookies object, which can be used to read cookies sent by the client. Use the method
Response.addHttpCookie()to add a cookie to the outgoing response.
- httpHeaders: Map
(read-only) Returns a Map containing all HTTP header values.
- httpHost: String
(read-only) Returns the host name or null if there is no host name.
- httpLocale: String
(read-only) Returns the locale or null if there is no associated locale.
- httpMethod: String
(read-only) Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
- httpParameterMap: HttpParameterMap
(read-only) Returns the parameter map that contains the HTTP parameters for the current request.
- httpParameters: Map
(read-only) Returns a Map containing the raw HTTP parameters sent to the server. The Map contains name/value pairs. Each name is a String and each value is a String array.
- httpPath: String
(read-only) Returns the path.
- httpProtocol: String
(read-only) Returns the HTTP protocol used for this request. Possible values are "http" or "https". If the current activity is not related to an HTTP request, for example, when the request is part of a job, this method returns null.
- httpQueryString: String
(read-only) Returns the query string or null if there is no query string.
- httpReferer: String
(read-only) Returns the referer or null if there is no referer.
- httpRemoteAddress: String
(read-only) Returns the remote address or null if no remote address is found.
httpRequest: Boolean(read-only)Identifies if this request is an HTTP request. The method returns true, if the current processing is related to a HTTP request.
Deprecated:
Effectively always returns true.
- httpSecure: Boolean
(read-only) Returns whether the HTTP communication is secure, which basically means that the communication happens via https. If the current activity is not related to an HTTP request the method returns false.
- httpURL: URL
(read-only) Returns the complete URL of the request which was received at the server. This URL does not include SEO optimizations.
- httpUserAgent: String
(read-only) Returns the HTTP user agent or null if there is no user agent.
- includeRequest: Boolean
(read-only) Returns true if the request represents a request for a remote include, false if it is a top-level request.
- locale: String
Returns the locale of the current request. This locale is set by the system based on the information in the URL. It may be different from the locale returned by getHttpLocale(), which is the preferred locale sent by the user agent.
- ocapiVersion: String
(read-only) Returns the OCAPI version of the current request. If this is not an OCAPI request, 'null' is returned.
- pageMetaData: PageMetaData
(read-only) Returns the page meta data that are associated with the current request.
- requestID: String
(read-only) Returns the unique identifier of the current request. The unique id is helpful for debugging purpose, e.g. relate debug messages to a particular request.
- session: Session
(read-only) Returns the session associated with this request.
- triggeredForm: Form
(read-only) Returns the form that was submitted by the client if the request represents a form submission.
- triggeredFormAction: FormAction
(read-only) Returns the form action that was triggered by the client if the request represents a form submission.
addHttpCookie(cookie: Cookie): voidAdds the specified cookie to the outgoing response. This method can be called multiple times to set more than one cookie. If a cookie with the same cookie name, domain and path is set multiple times for the same response, only the last set cookie with this name is send to the client. This method can be used to set, update or delete cookies at the client. If the cookie doesn't exist at the client, it is set initially. If a cookie with the same name, domain and path already exists at the client, it is updated. A cookie can be deleted at the client by submitting a cookie with the maxAge attribute set to 0 (see
Cookie.setMaxAge()for more information).Parameters:
- cookie - a Cookie object
Deprecated:
Use Response.addHttpCookie(Cookie) instead.
No longer available as of version 99.2. This method is deprecated and will be removed in the next API version.
- getClientId(): String
Returns the client id of the current SCAPI or OCAPI request. If the request is not a SCAPI request or not an OCAPI request 'null' is returned. For client ids owned by Commerce Cloud Digital an alias is returned.
Returns:
- a client id or alias in case of an OCAPI request, otherwise null.
- getCustom(): CustomAttributes
Returns all of the custom attributes associated with the request. The attributes are stored for the life time of the request.
Returns:
- all of the custom attributes associated with the request.
- getGeolocation(): Geolocation
Returns the physical location for the current request, if available. The location is calculated based on the IP address of the request. Note, if the geolocation tracking feature is not enabled, this method always returns null.
Returns:
- The geolocation of the current request, or null if this is not available.
- getHttpCookies(): Cookies
Returns the Cookies object, which can be used to read cookies sent by the client. Use the method
Response.addHttpCookie()to add a cookie to the outgoing response.Returns:
- Cookies object or null if this is not an HTTP request
- getHttpHeaders(): Map
Returns a Map containing all HTTP header values.
Returns:
- a Map containing all HTTP header values.
- getHttpHost(): String
Returns the host name or null if there is no host name.
Returns:
- the host name or null if there is no host name.
- getHttpLocale(): String
Returns the locale or null if there is no associated locale.
Returns:
- the locale or null.
- getHttpMethod(): String
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
Returns:
- the HTTP method
- getHttpParameterMap(): HttpParameterMap
Returns the parameter map that contains the HTTP parameters for the current request.
Returns:
- the HTTP parameter map
- getHttpParameters(): Map
Returns a Map containing the raw HTTP parameters sent to the server. The Map contains name/value pairs. Each name is a String and each value is a String array.
Returns:
- a Map containing all the raw HTTP parameters send to the server.
- getHttpPath(): String
Returns the path.
Returns:
- the path or null.
- getHttpProtocol(): String
Returns the HTTP protocol used for this request. Possible values are "http" or "https". If the current activity is not related to an HTTP request, for example, when the request is part of a job, this method returns null.
Returns:
- "http", "https" or null
- getHttpQueryString(): String
Returns the query string or null if there is no query string.
Returns:
- the query string or null.
- getHttpReferer(): String
Returns the referer or null if there is no referer.
Returns:
- the referer or null if there is no referer.
- getHttpRemoteAddress(): String
Returns the remote address or null if no remote address is found.
Returns:
- the remote address or null if no remote address is found.
- getHttpURL(): URL
Returns the complete URL of the request which was received at the server. This URL does not include SEO optimizations.
Returns:
- the URL as URL object
- getHttpUserAgent(): String
Returns the HTTP user agent or null if there is no user agent.
Returns:
- the HTTP user agent or null if there is no user agent.
- getLocale(): String
Returns the locale of the current request. This locale is set by the system based on the information in the URL. It may be different from the locale returned by getHttpLocale(), which is the preferred locale sent by the user agent.
Returns:
- the locale of the current request, like 'en_US'
- getOcapiVersion(): String
Returns the OCAPI version of the current request. If this is not an OCAPI request, 'null' is returned.
Returns:
- OCAPI version of the current request
- getPageMetaData(): PageMetaData
Returns the page meta data that are associated with the current request.
Returns:
- the page meta data object
- getRequestID(): String
Returns the unique identifier of the current request. The unique id is helpful for debugging purpose, e.g. relate debug messages to a particular request.
Returns:
- the unique identifier of the current request.
- getSCAPIPathParameters(): Map
Returns a map containing all path parameters of current SCAPI request in the following way:
- keys: path parameter names from path pattern
- values: corresponding path parameter values from current request
Returns null if isSCAPI() returns false i.e. if the request is not a SCAPI request.
For example:
- Current request:
/product/shopper-products/v1/organizations/sfcc_org/products/apple-ipod-shuffle - Path pattern:
/product/shopper-products/v1/organizations/{organizationId}/products/{id} - Result: Mapwith 2 key
pairs: organizationId:sfcc_organdid:apple-ipod-shuffle.
Returns:
- the path parameter map or null
- getSCAPIPathPattern(): String
Returns the SCAPI path pattern in the following way:
-
The first three segments
/api-family/api-name/versionwith concrete values. -
The /organizations part with the path parameter name
organizationIdin curly brackets. - The actual resource path additional path parameter names in curly brackets.
Returns null if isSCAPI() returns false i.e. if the request is not a SCAPI request.
For example, in the context of a request to get a single product from shopper-products API, this method would return
/product/shopper-products/v1/organizations/{organizationId}/products/{id}Returns:
- the path pattern or null.
-
The first three segments
- getSession(): Session
Returns the session associated with this request.
Returns:
- the session associated with this request.
- getTriggeredForm(): Form
Returns the form that was submitted by the client if the request represents a form submission.
Returns:
- the form which was triggered
- getTriggeredFormAction(): FormAction
Returns the form action that was triggered by the client if the request represents a form submission.
Returns:
- the action of the form that was triggered
isHttpRequest(): BooleanIdentifies if this request is an HTTP request. The method returns true, if the current processing is related to a HTTP request.
Returns:
- true if the current processing is related to a HTTP request, false otherwise.
Deprecated:
Effectively always returns true.
- isHttpSecure(): Boolean
Returns whether the HTTP communication is secure, which basically means that the communication happens via https. If the current activity is not related to an HTTP request the method returns false.
- isIncludeRequest(): Boolean
Returns true if the request represents a request for a remote include, false if it is a top-level request.
- isSCAPI(): Boolean
Returns whether the request originated in SCAPI.
Returns:
- true or false.
- setGeolocation(geoLocation: Geolocation): void
Sets the physical location for the current request and remembers the new value for the duration of the user session. So any subsequent calls to getGeolocation() will return this value
Parameters:
- geoLocation - the geolocation object to use
- setLocale(localeID: String): Boolean
Sets the given locale for the request. The locale is only set if it is valid, if it is active and if it is allowed for the current site.
Parameters:
- localeID - the locale ID to be set, like 'en_US'
Returns:
- true, if the locale was successfully set, false otherwise