Build a container (C#)
Version: 10.3
When working with Sitecore Experience Commerce Service API, you must include your Commerce Engine operations and commands within a container call. You can re-use the same container for different Commerce operations.
The following is an example of how to build a container class using C#:
RequestResponse
public Container AuthoringContainer()
{
var container = new Container(new Uri("https://localhost:5000/api/"))
{
MergeOption = MergeOption.OverwriteChanges, DisableInstanceAnnotationMaterialization = true };
container.BuildingRequest += (s, e) =>;
{
e.Headers.Add("ShopName", "CommerceEngineDefaultStorefront");
e.Headers.Add("Language", "en-us");
e.Headers.Add("Currency", "USD");
e.Headers.Add("Environment", "HabitatAuthoring");
e.Headers.Add("Authorization", SitecoreIdServerAuth.GetToken());
e.Headers.Add("UserId", "UserId");
e.Headers.Add("CustomerId", "CustomerId");
e.Headers.Add("IsRegistered", "false");
}; return container;
}