HomeGuides
Submit Documentation FeedbackJoin Developer CommunityLog In

Catalog entries

This topic describes how to work with RESTful operations for catalogs entries in the Optimizely Service API. The Service API supports published versions of catalogs (from version 1.0 and higher), as well as common draft versions of catalogs (from version 5.1.0).

Example models

[Serializable]
public class NameValue
  {
    public string Name { get; set; }
    public string Value { get; set; }
  }
[Serializable]
public class ResourceLink
  {
    public string Title { get; set; }
    public string Type { get; set; }
    public string Href { get; set; }
    public List<NameValue> Properties { get; set; }
  }  

[Serializable]
public class SeoInfo
  {
    public string Title { get; set; }
    public string Uri { get; set; }
    public string UriSegment { get; set; }
    public string Description { get; set; }
    public string Keywords { get; set; }
    public string LanguageCode { get; set; }
  }
    
[Serializable]
public class MetaFieldData
  {
    public string Language { get; set; }
    public string Value { get; set; }
  }

[Serializable]
public class MetaFieldProperty
  {
    public string Name { get; set; }
    public string Type { get; set; }
    public List<MetaFieldData> Data { get; set; }
  }

[Serializable]
public class VariationProperties
  {
    public decimal MinQuantity { get; set; }
    public decimal MaxQuantity { get; set; }
    public double Weight { get; set; }
    public String TaxCategory { get; set; }
  }

[Serializable]
public class DimensionProperties
  {
    public double Length { get; set; }
    public double Heigth { get; set; }
    public double Width {get; set; }
  }

[Serializable]
public class Entry
  {
    public Entry()
      {
        SeoInformation = new List<SeoInfo>();
        Assets = new List<ResourceLink>();
        Associations = new List<ResourceLink>();
        MetaFields = new List<MetaFieldProperty>();
        WarehouseInventories = new List<ResourceLink>();
        Prices = new List<ResourceLink>();
        ChildCatalogEntries = new List<ResourceLink>();
        Nodes = new List<ResourceLink>();
        ParentCatalogEntry = new ResourceLink();
        Variation = null;
      }
    public string Code { get; set; }
    public Guid? ApplicationId { get; set; }
    public string Name { get; set; }
    public ResourceLink ParentCatalogEntry { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
    public bool IsActive { get; set; }
    public string MetaClass { get; set; }
    public string Catalog { get; set; }
    public List<MetaFieldProperty> MetaFields { get; set; }
    public List<SeoInfo> SeoInformation { get; set; }
    public List<ResourceLink> Prices { get; set; }
    public string EntryType { get; set; }
    public List<ResourceLink> ChildCatalogEntries { get; set; }
    public string InventoryStatus { get; set; }
    public List<ResourceLink> WarehouseInventories { get; set; }
    public List<ResourceLink> Associations { get; set; }
    public List<ResourceLink> Assets { get; set; }
    public List<ResourceLink> Nodes { get; set; }
    public VariationProperties Variation { get; set; }
    public DimensionProperties Dimension {get; set; }
  }

[Serializable]
public class Entries
  {
    public Entries()
      {
        EntryResults = new List<Entry>();
        TotalCount = 0;
        TotalPages = 0;
      }
    public List<Entry> EntryResults { get; set; }
    public int TotalCount { get; set; }
    public int TotalPages { get; set; }
  }

Published catalog entries

Get all entries

GET

get/episerverapi/commerce/entries/{startPage}/{pageSize}

By default this method gets all languages for the entries. If you want only one specific language, use the Accept-Language header.

JSON response type

var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);        
var result = client.GetAsync("/episerverapi/commerce/entries/{startPage}/{pageSize}").Result.Content.ReadAsStringAsync().Result

XML response type

var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml"));       
var result = client.GetAsync("/episerverapi/commerce/entries/{startPage}/{pageSize}").Result.Content.ReadAsStringAsync().Result

Response

<Entries xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <EntryResults>
    <Entry>
      <Code>Jackets-Peacoats-Hooded</Code>
      <ApplicationId>b60ed82e-95b4-4f8b-ad43-2ce99f3b9470</ApplicationId>
      <Name>Jackets-Peacoats-Hooded</Name>
      <ParentCatalogEntry />
      <StartDate>2010-09-01T07:00:00Z</StartDate>
      <EndDate>2020-10-01T07:00:00Z</EndDate>
      <IsActive>true</IsActive>
      <MetaClass>Fashion_Product_Class</MetaClass>
      <Catalog>Departmental Catalog</Catalog>
      <MetaFields>
        <MetaFieldProperty>
          <Name>DisplayName</Name>
          <Type>ShortString</Type>
          <Data>
            <MetaFieldData>
              <Language>en</Language>
              <Value>Jackets-Peacoats-Hooded</Value>
            </MetaFieldData>
          </Data>
        </MetaFieldProperty>
        <MetaFieldProperty>
          <Name>Facet_Bestseller</Name>
          <Type>ShortString</Type>
          <Data>
            <MetaFieldData>
              <Language>en</Language>
              <Value>Yes</Value>
            </MetaFieldData>
          </Data>
        </MetaFieldProperty>
      <SeoInformation>
        <SeoInfo>
          <Title />
          <Uri>Jackets-Peacoats-Hooded.aspx</Uri>
          <UriSegment>Jackets-Peacoats-Hooded</UriSegment>
          <Description />
          <Keywords />
          <LanguageCode>en</LanguageCode>
        </SeoInfo>
      </SeoInformation>
      <Prices/>
      <EntryType>Product</EntryType>
      <ChildCatalogEntries>
        <ResourceLink>
          <Title>Jackets-Peacoats-Hooded-Tan-Small</Title>
          <Type>CatalogEntry</Type>
          <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small</Href>
        </ResourceLink>
        <ResourceLink>
          <Title>Jackets-Peacoats-Hooded-Tan-Medium</Title>
          <Type>CatalogEntry</Type>
          <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Medium</Href>
        </ResourceLink>
      </ChildCatalogEntries>
      <InventoryStatus>Disabled</InventoryStatus>
      <WarehouseInventories/>
      <Associations>
        <ResourceLink>
          <Title>CrossSell</Title>
          <Type>Association</Type>
          <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded/associations/CrossSell</Href>
        </ResourceLink>
        <ResourceLink>
          <Title>Default</Title>
          <Type>Association</Type>
          <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded/associations/Default</Href>
        </ResourceLink>
        <ResourceLink>
          <Title>UpSell</Title>
          <Type>Association</Type>
          <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded/associations/UpSell</Href>
        </ResourceLink>
      </Associations>
      <Assets>
        <ResourceLink>
          <Title>a9cd22ed-a43d-47d0-ba66-bf56a4e59fe9</Title>
          <Type>Asset</Type>
          <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded/assets/a9cd22ed-a43d-47d0-ba66-bf56a4e59fe9/episerver.core.icontentimage</Href>
        </ResourceLink>
      </Assets>
      <Nodes>
        <ResourceLink>
          <Title>Jackets-Peacoats</Title>
          <Type>CatalogNode</Type>
          <Href>/episerverapi/commerce/nodes/Jackets-Peacoats</Href>
        </ResourceLink>
      </Nodes>
    </Entry>
        <Entry xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Code>Jackets-Peacoats-Hooded-Tan-Small</Code>
        <ApplicationId>b60ed82e-95b4-4f8b-ad43-2ce99f3b9470</ApplicationId>
        <Name>Jackets-Peacoats-Hooded-Tan-Small</Name>
        <ParentCatalogEntry />
        <StartDate>2010-09-01T13:00:00Z</StartDate>
        <EndDate>2019-10-02T01:00:00Z</EndDate>
        <IsActive>true</IsActive>
        <MetaClass>Fashion_Item_Class</MetaClass>
        <Catalog>Departmental Catalog</Catalog>
        <MetaFields>
            <MetaFieldProperty>
                <Name>DisplayName</Name>
                <Type>ShortString</Type>
                <Data>
                    <MetaFieldData>
                        <Language>en</Language>
                        <Value>Jackets-Peacoats-Hooded-Tan-Small</Value>
                    </MetaFieldData>
                </Data>
            </MetaFieldProperty>
            <MetaFieldProperty>
                <Name>Facet_Color</Name>
                <Type>LongString</Type>
                <Data>
                    <MetaFieldData>
                        <Language>en</Language>
                        <Value>Tan</Value>
                    </MetaFieldData>
                </Data>
            </MetaFieldProperty>
        </MetaFields>
        <SeoInformation>
            <SeoInfo>
                <Title />
                <Uri>Jackets-Peacoats-Hooded-Tan-Small.aspx</Uri>
                <UriSegment>Jackets-Peacoats-Hooded-Tan-Small</UriSegment>
                <Description />
                <Keywords />
                <LanguageCode>en</LanguageCode>
            </SeoInfo>
        </SeoInformation>
        <Prices>
            <ResourceLink>
                <Title>$1,000.00</Title>
                <Type>Price</Type>
                <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/prices/246</Href>
            </ResourceLink>
            <ResourceLink>
                <Title>775,20 €</Title>
                <Type>Price</Type>
                <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/prices/247</Href>
            </ResourceLink>
        </Prices>
        <EntryType>Variation</EntryType>
        <ChildCatalogEntries />
        <InventoryStatus>Enabled</InventoryStatus>
        <WarehouseInventories>
            <ResourceLink>
                <Title>default - 10</Title>
                <Type>WarehouseInventory</Type>
                <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/inventories/default</Href>
            </ResourceLink>
            <ResourceLink>
                <Title>HELSINKI - 200</Title>
                <Type>WarehouseInventory</Type>
                <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/inventories/HELSINKI</Href>
            </ResourceLink>
        </WarehouseInventories>
        <Associations>
            <ResourceLink>
                <Title>CrossSell</Title>
                <Type>Association</Type>
                <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/associations/CrossSell</Href>
            </ResourceLink>
            <ResourceLink>
                <Title>Default</Title>
                <Type>Association</Type>
                <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/associations/Default</Href>
            </ResourceLink>
            <ResourceLink>
                <Title>UpSell</Title>
                <Type>Association</Type>
                <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/associations/UpSell</Href>
            </ResourceLink>
        </Associations>
        <Assets>
            <ResourceLink>
                <Title>f23cd583-baa8-4e8f-871e-22fee65b6b73</Title>
                <Type>Asset</Type>
                <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/assets/f23cd583-baa8-4e8f-871e-22fee65b6b73/episerver.core.icontentimage</Href>
            </ResourceLink>
        </Assets>
        <Nodes>
            <ResourceLink>
                <Title>Jackets-Peacoats</Title>
                <Type>CatalogNode</Type>
                <Href>/episerverapi/commerce/nodes/Jackets-Peacoats</Href>
            </ResourceLink>
        </Nodes>
        <Variation>
            <MinQuantity>1.0000</MinQuantity>
            <MaxQuantity>50.0000</MaxQuantity>
            <Weight>5</Weight>
            <TaxCategory />
        </Variation>
        <Dimension> 
          <Length>1.0000</Length> 
          <Heigth>50.0000</Heigth>
          <Width>5.0000</Width>
        </Dimension>
    </Entry>
    </EntryResults>
  <TotalCount>6066</TotalCount>
  <TotalPages>304</TotalPages>
</Entries>

Get a specific entry

GET

get/episerverapi/commerce/entries/{entryCode}

By default this method gets all languages for the entry. If you want only one specific language use the Accept-Language header.

JSON response type

var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);        
var result = client.GetAsync("/episerverapi/commerce/entries/{entry code}").Result.Content.ReadAsStringAsync().Result

XML response type

var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml"));       
var result = client.GetAsync("/episerverapi/commerce/entries/{entry code}").Result.Content.ReadAsStringAsync().Result

Response

<Entry xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Code>Jackets-Peacoats-Hooded-Tan-Small</Code>
  <ApplicationId>b60ed82e-95b4-4f8b-ad43-2ce99f3b9470</ApplicationId>
  <Name>Jackets-Peacoats-Hooded-Tan-Small</Name>
  <ParentCatalogEntry />
  <StartDate>2010-09-01T13:00:00Z</StartDate>
  <EndDate>2019-10-02T01:00:00Z</EndDate>
  <IsActive>true</IsActive>
  <MetaClass>Fashion_Item_Class</MetaClass>
  <Catalog>Departmental Catalog</Catalog>
  <MetaFields>
    <MetaFieldProperty>
      <Name>DisplayName</Name>
      <Type>ShortString</Type>
      <Data>
        <MetaFieldData>
          <Language>en</Language>
          <Value>Jackets-Peacoats-Hooded-Tan-Small</Value>
        </MetaFieldData>
      </Data>
    </MetaFieldProperty>
    <MetaFieldProperty>
      <Name>Facet_Color</Name>
      <Type>LongString</Type>
      <Data>
        <MetaFieldData>
          <Language>en</Language>
          <Value>Tan</Value>
        </MetaFieldData>
      </Data>
    </MetaFieldProperty>
  </MetaFields>
  <SeoInformation>
    <SeoInfo>
      <Title />
      <Uri>Jackets-Peacoats-Hooded-Tan-Small.aspx</Uri>
      <UriSegment>Jackets-Peacoats-Hooded-Tan-Small</UriSegment>
      <Description />
      <Keywords />
      <LanguageCode>en</LanguageCode>
    </SeoInfo>
  </SeoInformation>
  <Prices>
    <ResourceLink>
      <Title>$1,000.00</Title>
      <Type>Price</Type>
      <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/prices/246</Href>
    </ResourceLink>
    <ResourceLink>
      <Title>775,20 €</Title>
      <Type>Price</Type>
      <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/prices/247</Href>
    </ResourceLink>
  </Prices>
  <EntryType>Variation</EntryType>
  <ChildCatalogEntries />
  <InventoryStatus>Enabled</InventoryStatus>
  <WarehouseInventories>
    <ResourceLink>
      <Title>default - 10</Title>
      <Type>WarehouseInventory</Type>
      <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/inventories/default</Href>
    </ResourceLink>
    <ResourceLink>
      <Title>HELSINKI - 200</Title>
      <Type>WarehouseInventory</Type>
      <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/inventories/HELSINKI</Href>
    </ResourceLink>
  </WarehouseInventories>
  <Associations>
    <ResourceLink>
      <Title>CrossSell</Title>
      <Type>Association</Type>
      <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/associations/CrossSell</Href>
    </ResourceLink>
    <ResourceLink>
      <Title>Default</Title>
      <Type>Association</Type>
      <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/associations/Default</Href>
    </ResourceLink>
    <ResourceLink>
      <Title>UpSell</Title>
      <Type>Association</Type>
      <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/associations/UpSell</Href>
    </ResourceLink>
  </Associations>
  <Assets>
    <ResourceLink>
      <Title>f23cd583-baa8-4e8f-871e-22fee65b6b73</Title>
      <Type>Asset</Type>
      <Href>/episerverapi/commerce/entries/Jackets-Peacoats-Hooded-Tan-Small/assets/f23cd583-baa8-4e8f-871e-22fee65b6b73/episerver.core.icontentimage</Href>
    </ResourceLink>
  </Assets>
  <Nodes>
    <ResourceLink>
      <Title>Jackets-Peacoats</Title>
      <Type>CatalogNode</Type>
      <Href>/episerverapi/commerce/nodes/Jackets-Peacoats</Href>
    </ResourceLink>
  </Nodes>
  <Variation>
    <MinQuantity>1.0000</MinQuantity>
    <MaxQuantity>50.0000</MaxQuantity>
    <Weight>5</Weight>
    <TaxCategory />
  </Variation>
  <Dimension> 
    <Length>1.0000</Length> 
    <Height>50.0000</Height>
    <Width>5.0000</Width>
  </Dimension>
</Entry>

Create entry

POST

post/episerverapi/commerce/entries

Create entry.

JSON response type

var model = new Entry()
  {
    Code = "WhoKnewBaby",
    Catalog = "Departmental Catalog",
    EndDate = DateTime.UtcNow.AddDays(100),
    EntryType = "Product",
    InventoryStatus = "Enabled",
    IsActive = true,
    MetaClass = "Fashion_Product_Class",
    Name = "Test",
    StartDate = DateTime.UtcNow,
    MetaFields = new List<MetaFieldProperty>()
      {
        new MetaFieldProperty()
          {
            Name = "DisplayName",
            Type = "ShortString",
            Data = new List<MetaFieldData>()
              {
                new MetaFieldData()
                  {
                    Language="en",
                    Value = "DisplayName"
                  }
              }
          }
      },
    SeoInformation = new List<SeoInfo>()
      {
        new SeoInfo()
          {
            Description = "description",
            Keywords="",
            LanguageCode = "en",
            Title = "title",
            Uri = "whoknew",
            UriSegment = "whoknew"
          }
      }
  };
var json = JsonConvert.SerializeObject(model);
var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);    
var result = client.PostAsync("/episerverapi/commerce/entries",
             new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

XML response type

var model = new Entry()
  {
    Code = "WhoKnewBaby",
    Catalog = "Departmental Catalog",
    EndDate = DateTime.UtcNow.AddDays(100),
    EntryType = "Product",
    InventoryStatus = "Enabled",
    IsActive = true,
    MetaClass = "Fashion_Product_Class",
    Name = "Test",
    StartDate = DateTime.UtcNow,
    MetaFields = new List<MetaFieldProperty>()
      {
        new MetaFieldProperty()
          {
            Name = "DisplayName",
            Type = "ShortString",
            Data = new List<MetaFieldData>()
              {
                new MetaFieldData()
                  {
                    Language="en",
                    Value = "DisplayName"
                  }
              }
          }
      },
    SeoInformation = new List<SeoInfo>()
      {
        new SeoInfo()
          {
            Description = "description",
            Keywords="",
            LanguageCode = "en",
            Title = "title",
            Uri = "whoknew",
            UriSegment = "whoknew"
          }
      }
  };
var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(Entry));
var xml = String.Empty;
using (var ms = new MemoryStream())
  {
    serializer.Serialize(ms, model);
    xml = Encoding.Default.GetString(ms.ToArray());
  }   
var result = client.PostAsync("/episerverapi/commerce/entries", 
             new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result

Response

<Entry xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Code>WhoKnewBaby</Code>
  <ApplicationId xsi:nil="true" />
  <Name>Test</Name>
  <ParentCatalogEntry />
  <StartDate>2014-08-26T13:52:07.8312797Z</StartDate>
  <EndDate>2014-12-04T13:52:07.8312797Z</EndDate>
  <IsActive>true</IsActive>
  <MetaClass>Fashion_Product_Class</MetaClass>
  <Catalog>Departmental Catalog</Catalog>
  <MetaFields>
    <MetaFieldProperty>
      <Name>DisplayName</Name>
      <Type>ShortString</Type>
      <Data>
        <MetaFieldData>
          <Language>en</Language>
          <Value>DisplayName</Value>
        </MetaFieldData>
      </Data>
    </MetaFieldProperty>
  </MetaFields>
  <SeoInformation>
    <SeoInfo>
      <Title>title</Title>
      <Uri>whoknew</Uri>
      <UriSegment>whoknew</UriSegment>
      <Description>description</Description>
      <Keywords />
      <LanguageCode>en</LanguageCode>
    </SeoInfo>
  </SeoInformation>
  <Prices />
  <EntryType>Product</EntryType>
  <ChildCatalogEntries />
  <InventoryStatus>Enabled</InventoryStatus>
  <WarehouseInventories />
  <Associations />
  <Assets />
  <Nodes />
</Entry>

Update entry

PUT

put/episerverapi/commerce/entries/{entryCode}

Update entry

JSON response type

var model = new Entry()
  {
    Code = "Dresses-Cocktail-Silk",
    Catalog = "Departmental Catalog",
    EndDate = DateTime.UtcNow.AddDays(100),
    EntryType = "Product",
    InventoryStatus = "Enabled",
    IsActive = true,
    MetaClass = "Fashion_Product_Class",
    Name = "Test",
    StartDate = DateTime.UtcNow,
    MetaFields = new List<MetaFieldProperty>()
      {
        new MetaFieldProperty()
          {
            Name = "DisplayName",
            Type = "ShortString",
            Data = new List<MetaFieldData>()
              {
                new MetaFieldData()
                  {
                    Language="en",
                    Value = "Dresses-Cocktail-Silk"
                  }
              }
          }
      },
    SeoInformation = new List<SeoInfo>()
      {
        new SeoInfo()
          {
            Description = "description",
            Keywords="",
            LanguageCode = "en",
            Title = "title",
            Uri = "Dresses-Cocktail-Silk",
            UriSegment = "Dresses-Cocktail-Silk"
          }
      }
  };
var json = JsonConvert.SerializeObject(model);
var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);    
var result = client.PutAsync("/episerverapi/commerce/entries/{entry code}",
             new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

XML response type

var model = new Entry()
  {
    Code = "Dresses-Cocktail-Silk",
    Catalog = "Departmental Catalog",
    EndDate = DateTime.UtcNow.AddDays(100),
    EntryType = "Product",
    InventoryStatus = "Enabled",
    IsActive = true,
    MetaClass = "Fashion_Product_Class",
    Name = "Test",
    StartDate = DateTime.UtcNow,
    MetaFields = new List<MetaFieldProperty>()
      {
        new MetaFieldProperty()
          {
            Name = "DisplayName",
            Type = "ShortString",
            Data = new List<MetaFieldData>()
              {
                new MetaFieldData()
                  {
                    Language="en",
                    Value = "Dresses-Cocktail-Silk"
                  }
              }
          }
      },
    SeoInformation = new List<SeoInfo>()
      {
        new SeoInfo()
          {
            Description = "description",
            Keywords="",
            LanguageCode = "en",
            Title = "title",
            Uri = "Dresses-Cocktail-Silk",
            UriSegment = "Dresses-Cocktail-Silk"
          }
      }
  };
var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(Entry));
var xml = String.Empty;
using (var ms = new MemoryStream())
  {
    serializer.Serialize(ms, model);
    xml = Encoding.Default.GetString(ms.ToArray());
  }   
var result = client.PutAsync("/episerverapi/commerce/entries/{entry code}",
             new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result

Response

204 No Content

Delete entry

DELETE

delete/episerverapi/commerce/entries/{entryCode}

Delete entry

JSON response type

var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);        
var result = client.DeleteAsync("/episerverapi/commerce/entries/{entry code}").Result.Content.ReadAsStringAsync().Result

XML response type

var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml"));   
var result = client.DeleteAsync("/episerverapi/commerce/entries/{entry code}").Result.Content.ReadAsStringAsync().Result

Response

<Entry xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Code>WhoKnewBaby</Code>
  <ApplicationId xsi:nil="true" />
  <Name>Test</Name>
  <ParentCatalogEntry />
  <StartDate>2014-08-26T13:52:07.8312797Z</StartDate>
  <EndDate>2014-12-04T13:52:07.8312797Z</EndDate>
  <IsActive>true</IsActive>
  <MetaClass>Fashion_Product_Class</MetaClass>
  <Catalog>Departmental Catalog</Catalog>
  <MetaFields>
    <MetaFieldProperty>
      <Name>DisplayName</Name>
      <Type>ShortString</Type>
      <Data>
        <MetaFieldData>
          <Language>en</Language>
          <Value>DisplayName</Value>
        </MetaFieldData>
      </Data>
    </MetaFieldProperty>
  </MetaFields>
  <SeoInformation>
    <SeoInfo>
      <Title>title</Title>
      <Uri>whoknew</Uri>
      <UriSegment>whoknew</UriSegment>
      <Description>description</Description>
      <Keywords />
      <LanguageCode>en</LanguageCode>
    </SeoInfo>
  </SeoInformation>
  <Prices />
  <EntryType>Product</EntryType>
  <ChildCatalogEntries />
  <InventoryStatus>Enabled</InventoryStatus>
  <WarehouseInventories />
  <Associations />
  <Assets />
  <Nodes />
</Entry>

Common draft entries [New in Service API 5.1.0]

Use the endpoints listed below to get common draft versions, create new common drafts, and update or delete existing drafts.

Get common draft entry

GET

get/episerverapi/commerce/entries/{entryCode}/commondraft/{lang}

Get common draft entry

JSON response type

var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
var result = client.GetAsync("/episerverapi/commerce/entries/Code_1/commondraft/en").Result.Content.ReadAsStringAsync().Result;

XML response type

var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml"));
var result = client.GetAsync("/episerverapi/commerce/entries/Code_1/commondraft/en").Result.Content.ReadAsStringAsync().Result;

Response

<?xml version="1.0" encoding="UTF-8"?>
  <DraftEntry>
    <Assets />
    <Associations />
    <Catalog>TESTROOTCATALOG</Catalog>
    <ChildCatalogEntries />
    <Code>Code_1</Code>
    <EndDate>2020-07-26T07:22:34.793Z</EndDate>
    <EntryType>Variation</EntryType>
    <InventoryStatus>Enabled</InventoryStatus>
    <MetaClass>DefaultMetadataClass</MetaClass>
    <MetaFields>
      <element>
        <Data /> 
        <Name>AnotherMultilanguageString</Name>
        <Type>ShortString</Type>
      </element> 
      <element> 
        <Data /> 
        <Name>DecimalType</Name> 
        <Type>Decimal</Type>
      </element> 
      <element> 
        <Data>Testing Description</Data> 
        <Name>Description</Name> 
        <Type>LongString</Type> 
      </element> 
      <element>
        <Data>
          <element>Value2</element>
        </Data>
        <Name>DictionaryMulti</Name> 
        <Type>EnumMultiValue</Type>
      </element> 
      <element>
        <Data />
        <Name>DictionarySingle</Name> 
        <Type>DictionarySingleValue</Type> 
      </element> 
      <element> 
        <Data>Name_1</Data>
        <Name>DisplayName</Name>
        <Type>ShortString</Type>
      </element>
      <element>
        <Data />
        <Name>IntegerMetaFieldName</Name> 
        <Type>Int</Type> 
      </element>
      <element>
        <Data />
        <Name>AStringDictionaryMetaField</Name> 
        <Type>StringDictionary</Type>
      </element> 
      <element> 
        <Data /> 
        <Name>_ExcludedCatalogEntryMarkets</Name>
        <Type>EnumMultiValue</Type> 
      </element> 
    </MetaFields>
    <Name>Name_1</Name> 
    <Nodes> 
      <element>
        <Href>/episerverapi/commerce/nodes/TESTCATALOGTNODE</Href>
        <Properties>
          <element>
            <Name>Code</Name>
            <Value>TESTCATALOGTNODE</Value>
          </element> 
       </Properties> 
       <Title>TEST CATALOG NODE</Title>
       <Type>CatalogNode</Type>
      </element>
    </Nodes>
    <Prices /> 
    <SeoInformation>
      <Description>DESCRIPTION</Description> 
      <Keywords null="true" /> 
      <Title null="true" />
      <Uri>Uri_1</Uri>
      <UriSegment>name_1</UriSegment> 
    </SeoInformation> 
    <StartDate>2018-07-26T07:22:34.793Z</StartDate> 
    <Variation>
      <MaxQuantity>50.0</MaxQuantity>
      <MinQuantity>5.0</MinQuantity> 
      <TaxCategory /> <Weight>4.0</Weight>
    </Variation>
    <WarehouseInventories> 
      <element> 
        <Href>/episerverapi/commerce/entries/Code 1/inventories/default</Href> 
        <Properties null="true" /> 
        <Title>default - 10</Title> 
        <Type>WarehouseInventory</Type>
      </element> 
    </WarehouseInventories> 
  </DraftEntry>

Create common draft entry

📘

Note

The Optimizely Service API does not support creating common drafts for non-existing content. You can create a first draft version by using an endpoint for published content (without “commondraft”) and setting IsActive to “false”.

POST

post/episerverapi/commerce/entries/commondraft/{lang}

Create common draft entry

JSON response type

var _model = new DraftEntry
  {
    Code = "Code 3",
    Catalog = "TESTROOTCATALOG",
    EndDate = DateTime.UtcNow.AddDays(100),
    EntryType = "Variation",
    InventoryStatus = "Enabled",
    MetaClass = DefaultEntryMetaClassName,
    Name = "Test",
    StartDate = DateTime.UtcNow,
    MetaFields = new List<DraftMetaFieldProperty>
      {
         new DraftMetaFieldProperty
           {
             Name = "Description",
             Type = MetaDataType.LongHtmlString.ToString(),
             Data = "Description"
            },
         new DraftMetaFieldProperty()
           {
             Name = "DisplayName",
             Type = MetaDataType.ShortString.ToString(),
             Data = "DisplayName"
           },
         new DraftMetaFieldProperty
           {
              Name = "DecimalType",
              Type = MetaDataType.Decimal.ToString(),
              Data = $"{13.44.ToString(culture)}"
           },
         new DraftMetaFieldProperty
           {
              Name = "AnotherMultilanguageString",
              Type = MetaDataType.ShortString.ToString(),
              Data = "Set with lang key EN for en"
           },
         new DraftMetaFieldProperty
           {
               Name = "AStringDictionaryMetaField",
               Type = MetaDataType.StringDictionary.ToString(),
               Data = "Hello;world"
            },
         new DraftMetaFieldProperty
            {
               Name = "StringList",
               Type = MetaDataType.LongString.ToString(),
               Data = "[\"Item 1\",\"Item 2\"]"
            },
          new DraftMetaFieldProperty
            {
               Name = "IntList",
               Type = MetaDataType.LongString.ToString(),
               Data = $"[{10},{11},{12}]"
            },
          new DraftMetaFieldProperty
            {
               Name = "DoubleList",
               Type = MetaDataType.LongString.ToString(),
               Data = $"[{100.05.ToString(culture)},{100.06.ToString(culture)},{100.07.ToString(culture)},{100.08.ToString(culture)}]"
            },
          new DraftMetaFieldProperty
            {
               Name = "DateTimeList",
               Type = MetaDataType.LongString.ToString(),
               Data = $"[\"{DateTime.Now.ToString(culture)}\",\"{DateTime.Now.AddDays(1).ToString(culture)}\"]"
            }
      },
    Variation = new VariationProperties
      {
        MaxQuantity = 100,
        MinQuantity = 0,
        TaxCategory = "",
        Weight = 5.1,
      },
    Dimension = new DimensionProperties 
      { 
        Length= 100.34,
        Height = 0,
        Width= 5.1 
      }
  }
var json = JsonConvert.SerializeObject(model);
var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
var result = client.PostAsync("/episerverapi/commerce/entries/commondraft/en",
             new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result;

XML response type

var model = new DraftEntry
  {
    Code = "Code 3",
    Catalog = "Departmental Catalog",
    EndDate = DateTime.UtcNow.AddDays(100),
    EntryType = "Variation",
    InventoryStatus = "Enabled",
    MetaClass = "Fashion_Item_Class",
    Name = "Test",
    StartDate = DateTime.UtcNow,
    MetaFields = new List<DraftMetaFieldProperty>
      {
        new DraftMetaFieldProperty
          {
            Name = "Description",
            Type = MetaDataType.LongHtmlString.ToString(),
            Data = "Description"
          },
        new DraftMetaFieldProperty()
          {
            Name = "DisplayName",
            Type = MetaDataType.ShortString.ToString(),
            Data = "DisplayName"
          },
        new DraftMetaFieldProperty
          {
            Name = "DecimalType",
            Type = MetaDataType.Decimal.ToString(),
            Data = $"{13.44.ToString(culture)}"
          },
        new DraftMetaFieldProperty
          {
            Name = "AnotherMultilanguageString",
            Type = MetaDataType.ShortString.ToString(),
            Data = "Set with lang key EN for en"
          },
        new DraftMetaFieldProperty
          {
            Name = "AStringDictionaryMetaField",
            Type = MetaDataType.StringDictionary.ToString(),
            Data = "Hello;world"
          },
        new DraftMetaFieldProperty
          {
            Name = "StringList",
            Type = MetaDataType.LongString.ToString(),
            Data = "[\"Item 1\",\"Item 2\"]"
          },
        new DraftMetaFieldProperty
          {
            Name = "IntList",
            Type = MetaDataType.LongString.ToString(),
            Data = $"[{10},{11},{12}]"
          },
        new DraftMetaFieldProperty
          {
            Name = "DoubleList",
            Type = MetaDataType.LongString.ToString(),
            Data = $"[{100.05.ToString(culture)},{100.06.ToString(culture)},{100.07.ToString(culture)},{100.08.ToString(culture)}]"
          },
        new DraftMetaFieldProperty
          {
            Name = "DateTimeList",
            Type = MetaDataType.LongString.ToString(),
            Data = $"[\"{DateTime.Now.ToString(culture)}\",\"{DateTime.Now.AddDays(1).ToString(culture)}\"]"
          }
      },
    Variation = new VariationProperties
      {
        MaxQuantity = 100,
        MinQuantity = 0,
        TaxCategory = "",
        Weight = 5.1
      },
    Dimension = new DimensionProperties 
      { 
        Length= 100.34,
        Height = 0,
        Width= 5.1 
       }
  };
var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);\
var serializer = new XmlSerializer(typeof(DraftEntry));
var xml = string.Empty;
using (var ms = new MemoryStream())
  {
    serializer.Serialize(ms, _model);
    xml = Encoding.Default.GetString(ms.ToArray());
  } 
var result = client.PostAsync("/episerverapi/commerce/entries/commondraft/en",
             new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result;

Response

<?xml version="1.0" encoding="UTF-8"?>
  <DraftEntry>
    <Assets />
    <Associations />
    <Catalog>TESTROOTCATALOG</Catalog>
    <ChildCatalogEntries />
    <Code>Code 3</Code>
    <EndDate>2018-11-03T07:26:15.1234866Z</EndDate>
    <EntryType>Variation</EntryType>
    <InventoryStatus>Enabled</InventoryStatus>
    <MetaClass>CustomEntryMetadataClass</MetaClass>
    <MetaFields>
      <element>
        <Data>Description</Data>
        <Name>Description</Name>
        <Type>LongHtmlString</Type>
      </element>
      <element>
        <Data>DisplayName</Data>
        <Name>DisplayName</Name>
        <Type>ShortString</Type>
      </element>
      <element>
        <Data>13.44</Data>
        <Name>DecimalType</Name>
        <Type>Decimal</Type>
      </element>
      <element>
        <Data>Set with lang key EN for en</Data>
        <Name>AnotherMultilanguageString</Name>
        <Type>ShortString</Type>
      </element>
      <element>
        <Data>Hello;world</Data>
        <Name>AStringDictionaryMetaField</Name>
        <Type>StringDictionary</Type>
      </element>
      <element>
        <Data>
          <element>Item 1    </element>
          <element>Item 2    </element>
        </Data>
        <Name>StringList</Name>
        <Type>LongString</Type>
      </element>
      <element>
        <Data>
          <element>10    </element>
          <element>11    </element>
          <element>12    </element>
        </Data>
        <Name>IntList</Name>
        <Type>LongString</Type>
      </element>
      <element>
        <Data>
          <element>100.05    </element>
          <element>100.06    </element>
          <element>100.07    </element>
          <element>100.08    </element>
        </Data>
        <Name>DoubleList</Name>
        <Type>LongString</Type>
      </element>
      <element>
        <Data>
          <element>7/26/2018 2:26:15 PM    </element>
          <element>7/27/2018 2:26:15 PM    </element>
        </Data>
        <Name>DateTimeList</Name>
        <Type>LongString</Type>
      </element>
    </MetaFields>
    <Name>Test</Name>
    <Nodes />
    <Prices />
    <SeoInformation>
      <Description null="true" />
      <Keywords null="true" />
      <Title null="true" />
      <Uri null="true" />
      <UriSegment null="true" />
    </SeoInformation>
     <StartDate>2018-07-26T07:26:15.1234866Z</StartDate>
    <Variation>
      <MaxQuantity>100.0</MaxQuantity>
      <MinQuantity>0.0</MinQuantity>
      <TaxCategory />
      <Weight>5.1</Weight>
    </Variation>
    <WarehouseInventories />
  </DraftEntry>

Update common draft entry

📘

Note

If common draft content is in “Published” state, a new common draft version is created (same behavior as Post common draft). If common draft content is in a DelayedPublish/AwaitingApproval/CheckedIn state, then it skips updating content and returns a Conflict status code (409).

PUT

put/episerverapi/commerce/entries/{entryCode}/commondraft/{lang}

Update common draft entry

JSON response type

var entryLink = ReferenceConverter.GetContentLink(“Code_1”, CatalogContentType.CatalogEntry);
var entry = ContentLoader.Get<EntryContentBase>(entryLink);
if (entry != null)
  {
    _model = ServiceLocator.Instance.GetInstance<EntryModelFactory>()
    .CreateDraftEntryModel(entry, "");
    _model.Name = "Put Test";
    _model.SeoInformation.Uri = "NewEntryUri";
   
    var json = JsonConvert.SerializeObject(_model);
    var client = new HttpClient()
      {
        BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
      };
    client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
    var result = client.PutAsync("/episerverapi/commerce/entries/Code_1/commondraft/en", 
                 new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result;  
  }

XML response type

var entryLink = ReferenceConverter.GetContentLink(“Code_1”, CatalogContentType.CatalogEntry);
var entry = ContentLoader.Get<EntryContentBase>(entryLink);
if (entry != null)
  {
    _model = ServiceLocator.Instance.GetInstance<EntryModelFactory>()
    .CreateDraftEntryModel(entry, "");
    _model.Name = "Put Test";
    _model.SeoInformation.Uri = "NewEntryUri";
   
    var client = new HttpClient()
      {
        BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
      };
     client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
    var serializer = new XmlSerializer(typeof(DraftEntry));
    var xml = string.Empty;
    using (var ms = new MemoryStream())
      {
        serializer.Serialize(ms, _model);
        xml = Encoding.Default.GetString(ms.ToArray());
      }
    var result = client.PutAsync("/episerverapi/commerce/entries/Code_1/commondraft/en", 
                 new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result;  
  }

Response

204 No Content

Delete common draft entry

DELETE

delete/episerverapi/commerce/entries/{entryCode}/commondraft/{lang}

Delete common draft entry

JSON response type

var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
var result = client.DeleteAsync("/episerverapi/commerce/entries/Code_1/commondraft/en").Result.Content.ReadAsStringAsync().Result;

XML response type

var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml"));
var result = client.DeleteAsync("/episerverapi/commerce/entries/Code_1/commondraft/en").Result.Content.ReadAsStringAsync().Result;

Response

200 OK

Special strings and characters

Special strings

Theses properties require special values to function properly.

InventoryStatus

  • Enabled
  • Disabled
  • Ignored

EntryType

  • Product
  • Variation
  • Package
  • Bundle
  • DynamicPackage

Special characters in entry code [New version 5.4.2]

As of version 5.4.2, the Service API supports special characters (such as "/", "%" or "+") in the entry code for all actions (get all, get a specific, post, put or delete) for these objects:

  • Catalog entry
  • Catalog entry association
  • Catalog entry relation
  • Catalog item asset
  • Catalog entry price

The special characters must be double-encoded then sent to the Service API. For example, the slash character (/) is double-encoded as %252F.

📘

Note

Because double escaping in URLs involves security risks, it is preferable to avoid this approach.

To enable double-encoding support, edit the site 's web.config file as shown below:

<system.webServer>
    <security>
        <requestFiltering allowDoubleEscaping="true"/>
    </security>
</system.webServer>

<httpRuntime requestPathInvalidCharacters="&lt;,&gt;,*,&amp;,:,\,?" />

📘

Note

The characters listed after requestPathInvalidCharacters are only an example of special characters for which you can enable double-encoding support. You can modify the list as needed.


Did this page help you?