Loading...
Area: Optimizely Service API
Applies to versions: 1 and higher

Catalog entry relations

Recommended reading 

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

In this topic

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

get/episerverapi/commerce/entries/{entryCode}/entryrelations

JSON response type

C# code sample

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

Get entry relation

get/episerverapi/commerce/entries/{entryCode}/entryrelations/{childCode}/{relationType}

JSON response type

C# code sample

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

Create entry relation

post/episerverapi/commerce/entries/{entryCode}/entryrelations

JSON response type

C# code sample

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

Update entry relation

put/episerverapi/commerce/entries/{entryCode}/entryrelations/{childCode}/{relationType}

JSON response type

C# code sample

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

Delete entry relation

delete/episerverapi/commerce/entries/{entryCode}/entryrelations/{childCode}/{relationType}

JSON response type

C# code sample

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

Special strings

These properties require special values to function properly.

RelationType

  • ProductVariation
  • PackageEntry
  • BundleEntry

Related topics

Do you find this information helpful? Please log in to provide feedback.

Last updated: Oct 20, 2016

Recommended reading