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

Catalog node relations

Recommended reading 

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

In this topic

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

get/episerverapi/commerce/nodes/{nodeCode}/noderelations

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

XML response type

Get a specific node relation

get/episerverapi/commerce/nodes/{nodeCode}/noderelations/{childCode}

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

XML response type

Create node relation

post/episerverapi/commerce/nodes/{nodeCode}/noderelations

JSON response type

C# code sample

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

Update node relation

put/episerverapi/commerce/nodes/{nodeCode}/noderelations/{childCode}

JSON response type

C# code sample

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

Delete node relation

delete/episerverapi/commerce/nodes/{nodeCode}/noderelations/{childCode}

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

XML response type

Related topics

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

Last updated: Oct 20, 2016

Recommended reading