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

Catalog entry node relations

Recommended reading 

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

In this topic

Example models

[Serializable]
public class NodeEntryRelation
  {
    public int SortOrder { get; set; }
    public string NodeCode { get; set; }
    public string EntryCode { get; set; }
    public bool? IsPrimary { get; set; } //Optinal, if missing will be treated as False
  }

Get all entry node relations

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

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

XML response type

Get a specific entry node relation

get/episerverapi/commerce/entries/{entryCode}/nodeentryrelations/{nodeCode}

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

XML response type

Create entry node relation

Note: Setting a NodeEntryRelation with IsPrimary = true makes the current primary relation for that entry non-primary.

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

JSON response type

C# code sample

var model = new NodeEntryRelation()
  {
    EntryCode = "Tops-Tunics-LongSleeve",
    NodeCode = "Tops-Sweaters",
    SortOrder = 0,
    IsPrimary = true
  };
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}/nodeentryrelations", 
  new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

XML response type

Update entry node relation

Note: Setting a NodeEntryRelation with IsPrimary = true makes the current primary relation for that entry non-primary.

put/episerverapi/commerce/entries/{entryCode}/nodeentryrelations/{nodeCode}

JSON response type

C# code sample

var model = new NodeEntryRelation()
  {
    EntryCode = "Tops-Tunics-LongSleeve",
    NodeCode = "Tops-Sweaters",
    SortOrder = 0,
    IsPrimary = true
  };
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}/nodeentryrelations/{node code}",
  new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

XML response type

Delete entry node relation

delete/episerverapi/commerce/entries/{entryCode}/nodeentryrelations/{nodeCode}

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

XML response type

Related topics

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

Last updated: Oct 04, 2017

Recommended reading