Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Catalog node relations

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

Example models

[Serializable]
public class NodeRelation
  {
    public int SortOrder { get; set; }
    public string ParentNodeCode { get; set; }
    public string ChildNodeCode { get; set; }
  }

Get all node relations

GETget/episerverapi/commerce/nodes/{nodeCode}/noderelationsGet all node relations

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/nodes/{node code}/noderelations").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/nodes/{node code}/noderelations").Result.Content.ReadAsStringAsync().Result

Response

<ArrayOfNodeRelation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NodeRelation>
    <SortOrder>0</SortOrder>
    <ParentNodeCode>Books</ParentNodeCode>
    <ChildNodeCode>Bottoms</ChildNodeCode>
  </NodeRelation>
</ArrayOfNodeRelation>

Get a specific node relation

GETget/episerverapi/commerce/nodes/{nodeCode}/noderelations/{childCode}Get a specific node 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/nodes/{node code}/noderelations/{childCode}").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/nodes/{node code}/noderelations/{childCode}").Result.Content.ReadAsStringAsync().Result

Response

<NodeRelation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SortOrder>0</SortOrder>
  <ParentNodeCode>Books</ParentNodeCode>
  <ChildNodeCode>Bottoms</ChildNodeCode>
</NodeRelation>

Create node relation

PUTpost/episerverapi/commerce/nodes/{nodeCode}/noderelationsCreate node relation

JSON response type

var model = new NodeRelation()
  {
    ChildNodeCode = "Bottoms",
    ParentNodeCode = "Books",
    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/nodes/{node code}/noderelations", 
  new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

XML response type

var model = new NodeRelation()
  {
    ChildNodeCode = "Bottoms",
    ParentNodeCode = "Books",
    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(NodeRelation));
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/nodes/{node code}/noderelations", 
  new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result

Response

<NodeRelation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SortOrder>0</SortOrder>
  <ParentNodeCode>Books</ParentNodeCode>
  <ChildNodeCode>Bottoms</ChildNodeCode>
</NodeRelation>

Update node relation

PUTput/episerverapi/commerce/nodes/{nodeCode}/noderelations/{childCode}Update node relation

JSON response type

var model = new NodeRelation()
  {
    ChildNodeCode = "Bottoms",
    ParentNodeCode = "Books",
    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/nodes/{node code}/noderelations/{childCode}",
  new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

XML response type

var model = new NodeRelation()
  {
    ChildNodeCode = "Bottoms",
    ParentNodeCode = "Books",
    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(NodeRelation));
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/nodes/{node code}/noderelations/{childCode}",
  new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result

Response

204 No Content

Delete node relation

DELETEdelete/episerverapi/commerce/nodes/{nodeCode}/noderelations/{childCode}Delete node 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/nodes/{node code}/noderelations/{childCode}").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/nodes/{node code}/noderelations/{childCode}").Result.Content.ReadAsStringAsync().Result

Response

<NodeRelation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SortOrder>0</SortOrder>
  <ParentNodeCode>Books</ParentNodeCode>
  <ChildNodeCode>Bottoms</ChildNodeCode>
</NodeRelation>