Reuse a hostname over multiple sandboxes by creating a non-unique alias and generating
a registration link to access the sandbox.
Reusing a hostname alias enables you to do local testing by accessing the sandbox
without a proxy or CDN between the node and the sandbox. This option requires sending a
cookie manually with every request or by using a registration link.
Note: Before defining a sandbox alias, define a custom host name, such as
www.merchant.com
, in your siteβs alias configuration under .
Define a reusable on-demand sandbox alias using the POST
/sandboxes/{sandboxId}/aliases
method.
-
To open the Sandbox API user interface, go to B2C Commerce Sandbox API.
-
Click Authorize.
-
Enter the API client ID for the Sandbox API.
-
To dismiss the authorization window and return to the Sandbox API user interface,
click Close.
-
In the Common section, click to expand the
GET/system
method.
-
Click Try it out.
-
Click Execute.
The results contain one or more string values. These values appear as IP
addresses surrounded by quotation marks, for example,
"3.210.241.243".
-
Copy a string value and add it, along with the custom hostname, to your local
hosts
file, for example, 3.210.241.243
www.merchant.com. You need admin rights to edit this file.
-
In the Sandboxes section of the Sandbox API user interface, click to expand the
GET /sandboxes
method
-
Click Try it out.
-
Click Execute.
-
From the results, copy the desired Sandbox ID.
-
In the Sandboxes section, click to expand the
POST
/sandboxes/{sandboxId}/aliases
method
-
Click Try it out.
-
Register the hostname by editing the alias value (1), adding the hostname (2), and
specifying the Sandbox ID copied (3).
Note: The API payload supports a unique hostname parameter. Unless you explicitly set
it, the unique parameter is assumed to be false
. If you're using
one hostname for multiple sandboxes, you can either omit the unique setting from
the payload or specify a value of false
.
{
"name": "www.merchant.com",
"unique": false
}
-
Click Execute.
The call response generates a cookie and provides a registration
URL.
-
Copy the registration URL from the call response, and paste the link into a
browser.
After a short time, the browser redirects to the sandbox alias where you can
perform SEO testing.
What If I Donβt Use a Browser?
When testing REST APIs, you typically donβt use default browser access to a site. When
using tools like Curl or Postman, you define a cookie header manually using the hostname
and information that you obtain from the GET /system
API response.
For example,
curl -X GET -k -H 'Cookies:
b2codds_df69b6df-a4fb-3e8b-ada3-d0ded26e9fe0=83f05593-6272-382f-be1c-bc8e5021a243'
'https://www.merchant.com/dw/shop/v20_1/products/foo'