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
GET | get/episerverapi/commerce/nodes/{nodeCode}/noderelations | Get 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
GET | get/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
PUT | post/episerverapi/commerce/nodes/{nodeCode}/noderelations | Create 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
PUT | put/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
DELETE | delete/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>
Updated over 1 year ago
Next