HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In

Catalog entry relations

Describes how to work with RESTful operations for catalog entry relations in the Optimizely Service API.

Example models

[Serializable]
public class EntryRelation
  {
    public int SortOrder { get; set; }
    public decimal Quantity { get; set; }
    public string RelationType { get; set; }
    public string GroupName { get; set; }
    public string ParentEntryCode { get; set; }
    public string ChildEntryCode { get; set; }
  }

Get all entry relations

GETget/episerverapi/commerce/entries/{entryCode}/entryrelationsGet all entry relations

JSON response type

ar 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}/entryrelations").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}/entryrelations").Result.Content.ReadAsStringAsync().Result

Response

<ArrayOfEntryRelation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <EntryRelation>
    <SortOrder>0</SortOrder>
    <Quantity>1.0000</Quantity>
    <RelationType>ProductVariation</RelationType>
    <GroupName>default</GroupName>
    <ParentEntryCode>Jackets-Peacoats-Asymmetrical</ParentEntryCode>
    <ChildEntryCode>Jackets-Peacoats-Hooded-Tan-Large</ChildEntryCode>
  </EntryRelation>
  <EntryRelation>
    <SortOrder>0</SortOrder>
    <Quantity>1.0000</Quantity>
    <RelationType>ProductVariation</RelationType>
    <GroupName>default</GroupName>
    <ParentEntryCode>Jackets-Peacoats-Asymmetrical</ParentEntryCode>
    <ChildEntryCode>Jackets-Peacoats-Asymmetrical-Black-Small</ChildEntryCode>
  </EntryRelation>
  <EntryRelation>
    <SortOrder>0</SortOrder>
    <Quantity>1.0000</Quantity>
    <RelationType>ProductVariation</RelationType>
    <GroupName>default</GroupName>
    <ParentEntryCode>Jackets-Peacoats-Asymmetrical</ParentEntryCode>
    <ChildEntryCode>Jackets-Peacoats-Asymmetrical-Black-Medium</ChildEntryCode>
  </EntryRelation>
</ArrayOfEntryRelation>

Get entry relation

GETget/episerverapi/commerce/entries/{entryCode}/entryrelations/{childCode}/{relationType}Get entry relation

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}/entryrelations/{childCode}/{relationType}").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}/entryrelations/{childCode}/{relationType}").Result.Content.ReadAsStringAsync().Result

Response

<EntryRelation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SortOrder>0</SortOrder>
  <Quantity>1.0000</Quantity>
  <RelationType>ProductVariation</RelationType>
  <GroupName>default</GroupName>
  <ParentEntryCode>Jackets-Peacoats-Asymmetrical</ParentEntryCode>
  <ChildEntryCode>Jackets-Peacoats-Asymmetrical-Black-Small</ChildEntryCode>
</EntryRelation>

Create entry relation

POSTpost/episerverapi/commerce/entries/{entryCode}/entryrelationsCreate entry relation

JSON response type

ar model = new EntryRelation()
  {
    ChildEntryCode = "Jackets-Peacoats-Hooded-Tan-Large",
    GroupName = "default",
    ParentEntryCode = "Jackets-Peacoats-Asymmetrical",    
    Quantity = 1,
    RelationType = "ProductVariation",
    SortOrder = 0
  };
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/{entry code}/entryrelations",
  new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

XML response type

var model = new EntryRelation()
  {
    ChildEntryCode = "Jackets-Peacoats-Hooded-Tan-Large",
    GroupName = "default",
    ParentEntryCode = "Jackets-Peacoats-Asymmetrical",
    Quantity = 1,
    RelationType = "ProductVariation",
    SortOrder = 0
  };
var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(EntryRelation));
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/{entry code}/entryrelations",
  new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result

Response

<EntryRelation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SortOrder>0</SortOrder>
  <Quantity>1</Quantity>
  <RelationType>ProductVariation</RelationType>
  <GroupName>default</GroupName>
  <ParentEntryCode>Jackets-Peacoats-Asymmetrical</ParentEntryCode>
  <ChildEntryCode>Jackets-Peacoats-Hooded-Tan-Large</ChildEntryCode>
</EntryRelation>

Update entry relation

PUTput/episerverapi/commerce/entries/{entryCode}/entryrelations/{childCode}/{relationType}Update entry relation

JSON response type

var model = new EntryRelation()
  {
    ChildEntryCode = "Jackets-Peacoats-Hooded-Tan-Large",
    GroupName = "default",
    ParentEntryCode = "Jackets-Peacoats-Asymmetrical",
    Quantity = 1,
    RelationType = "ProductVariation",
    SortOrder = 0
  };
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}/entryrelations/{childCode}/{relationType}",
  new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

XML response type

var model = new EntryRelation()
  {
    ChildEntryCode = "Jackets-Peacoats-Hooded-Tan-Large",
    GroupName = "default",
    ParentEntryCode = "Jackets-Peacoats-Asymmetrical",
    Quantity = 1,
    RelationType = "ProductVariation",
    SortOrder = 0
  };
var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(EntryRelation));
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}/entryrelations/{childCode}/{relationType}",
  new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result

Response

204 No Content

Delete entry relation

DELETEdelete/episerverapi/commerce/entries/{entryCode}/entryrelations/{childCode}/{relationType}Delete entry relation

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}/entryrelations/{childCode}/{relationType}").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}/entryrelations/{childCode}/{relationType}").Result.Content.ReadAsStringAsync().Result

Response

<EntryRelation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SortOrder>0</SortOrder>
  <Quantity>1</Quantity>
  <RelationType>ProductVariation</RelationType>
  <GroupName>default</GroupName>
  <ParentEntryCode>Jackets-Peacoats-Asymmetrical</ParentEntryCode>
  <ChildEntryCode>Jackets-Peacoats-Hooded-Tan-Large</ChildEntryCode>
</EntryRelation>

Special strings

These properties require special values to function properly.

RelationType

  • ProductVariation
  • PackageEntry
  • BundleEntry