This topic describes how to work with RESTful operations for catalog nodes in the Episerver Service API.
In this topic
- Example models
- Get all nodes
- Get node
- Post node
- Put node
- Delete Node
- Get common draft node
- Post common draft node
- Put common draft node
- Delete common draft node
Example models
[Serializable]
public class NameValue
{
public string Name { get; set; }
public string Value { get; set; }
}
[Serializable]
public class ResourceLink
{
public string Title { get; set; }
public string Type { get; set; }
public string Href { get; set; }
public List<NameValue> Properties { get; set; }
}
[Serializable]
public class SeoInfo
{
public string Title { get; set; }
public string Uri { get; set; }
public string UriSegment { get; set; }
public string Description { get; set; }
public string Keywords { get; set; }
public string LanguageCode { get; set; }
}
[Serializable]
public class MetaFieldData
{
public string Language { get; set; }
public string Value { get; set; }
}
[Serializable]
public class MetaFieldProperty
{
public string Name { get; set; }
public string Type { get; set; }
public List<MetaFieldData> Data { get; set; }
}
[Serializable]
public class Node
{
public Node()
{
SeoInformation = new List<SeoInfo>();
Assets = new List<ResourceLink>();
MetaFields = new List<MetaFieldProperty>();
Children = new List<ResourceLink>();
Entries = new List<ResourceLink>();
}
public string Code { get; set; }
public string ParentNodeCode { get; set; }
public string Name { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public bool IsActive { get; set; }
public string MetaClass { get; set; }
public string Catalog { get; set; }
public int SortOrder { get; set; }
public ResourceLink ParentNode { get; set; }
public List<MetaFieldProperty> MetaFields { get; set; }
public List<SeoInfo> SeoInformation { get; set; }
public List<ResourceLink> Assets { get; set; }
public List<ResourceLink> Children { get; set; }
public List<ResourceLink> Entries { get; set; }
}
Get All Nodes
/episerverapi/commerce/catalog/{catalogName}/nodes
By default this method gets all languages for the nodes and entries. If you want only one specific language, use the Accept-Language header.
Client Code Media Type JSON
var client = new HttpClient()
{
BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var result = client.GetAsync("/episerverapi/commerce/catalog/{catalogName}/nodes").Result.Content.ReadAsStringAsync().Result
Response JSON
[
{
"Code" : "Departments",
"ParentNodeCode" : null,
"Name" : "Departments",
"StartDate" : "2010-09-01T07:00:00Z",
"EndDate" : "2020-10-01T07:00:00Z",
"IsActive" : true,
"MetaClass" : "DepartmentStoreLandingNode",
"Catalog" : "Departmental Catalog",
"SortOrder" : 1,
"ParentNode" : null,
"MetaFields" : [
{
"Name" : "DisplayName",
"Type" : "ShortString",
"Data" : [
{
"Language" : "en",
"Value" : "Departments"
}
]
},
{
"Name" : "Info_Description",
"Type" : "LongHtmlString",
"Data" : [
{
"Language" : "en",
"Value" : "Integer
posuere erat a ante venenatis dapibus posuere velit aliquet.
Vestibulum id ligula porta felis euismod semper.
Maecenas faucibus mollis interdum."
}
]
},
{
"Name" : "Info_Promotional_Message",
"Type" : "LongHtmlString",
"Data" : [
{
"Language" : "en",
"Value" : ""
}
]
}
],
"SeoInformation" : [
{
"Title" : "",
"Uri" : "Departments.aspx",
"UriSegment" : null,
"Description" : "",
"Keywords" : "",
"LanguageCode" : "en"
}
],
"Assets" : [],
"Children" : [],
"Entries" : [
{
"Title" : "Bundle Grundle",
"Type" : "CatalogEntry",
"Href" : "/episerverapi/commerce/entries/bundle"
},
{
"Title" : "Package Smackage",
"Type" : "CatalogEntry",
"Href" : "/episerverapi/commerce/entries/package"
}
]
},
{
"Code" : "Fashion",
"ParentNodeCode" : "Departments",
"Name" : "Fashion",
"StartDate" : "2010-09-01T07:00:00Z",
"EndDate" : "2020-10-01T07:00:00Z",
"IsActive" : true,
"MetaClass" : "FashionStoreLandingNode",
"Catalog" : "Departmental Catalog",
"SortOrder" : 1,
"ParentNode" : {
"Title" : "Departments",
"Type" : "CatalogNode",
"Href" : "/episerverapi/commerce/nodes/Departments"
},
"MetaFields" : [
{
"Name" : "DisplayName",
"Type" : "ShortString",
"Data" : [
{
"Language" : "en",
"Value" : "Fashion"
}
]
},
{
"Name" : "Info_Description",
"Type" : "LongHtmlString",
"Data" : [
{
"Language" : "en",
"Value" : "Integer
posuere erat a ante venenatis dapibus posuere velit aliquet.
Vestibulum id ligula porta felis euismod semper.
Maecenas faucibus mollis interdum."
}
]
},
{
"Name" : "Info_Promotional_Message",
"Type" : "LongHtmlString",
"Data" : [
{
"Language" : "en",
"Value" : ""
}
]
}
],
"SeoInformation" : [
{
"Title" : "",
"Uri" : "Fashion.aspx",
"UriSegment" : null,
"Description" : "",
"Keywords" : "",
"LanguageCode" : "en"
}
],
"Assets" : [],
"Children" : [],
"Entries" : []
}
]
Client Code Media Type XML
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").Result.Content.ReadAsStringAsync().Result
Response XML
<ArrayOfNode xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Node>
<Code>Departments</Code>
<Name>Departments</Name>
<StartDate>2010-09-01T07:00:00Z</StartDate>
<EndDate>2020-10-01T07:00:00Z</EndDate>
<IsActive>true</IsActive>
<MetaClass>DepartmentStoreLandingNode</MetaClass>
<Catalog>Departmental Catalog</Catalog>
<SortOrder>1</SortOrder>
<MetaFields>
<MetaFieldProperty>
<Name>DisplayName</Name>
<Type>ShortString</Type>
<Data>
<MetaFieldData>
<Language>en</Language>
<Value>Departments</Value>
</MetaFieldData>
</Data>
</MetaFieldProperty>
<MetaFieldProperty>
<Name>Info_Description</Name>
<Type>LongHtmlString</Type>
<Data>
<MetaFieldData>
<Language>en</Language>
<Value><p>Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper. Maecenas faucibus mollis interdum.</p></Value>
</MetaFieldData>
</Data>
</MetaFieldProperty>
<MetaFieldProperty>
<Name>Info_Promotional_Message</Name>
<Type>LongHtmlString</Type>
<Data>
<MetaFieldData>
<Language>en</Language>
<Value />
</MetaFieldData>
</Data>
</MetaFieldProperty>
</MetaFields>
<SeoInformation>
<SeoInfo>
<Title />
<Uri>Departments.aspx</Uri>
<Description />
<Keywords />
<LanguageCode>en</LanguageCode>
</SeoInfo>
</SeoInformation>
<Assets />
<Children />
<Entries>
<ResourceLink>
<Title>Bundle Grundle</Title>
<Type>CatalogEntry</Type>
<Href>/episerverapi/commerce/entries/bundle</Href>
</ResourceLink>
<ResourceLink>
<Title>Package Smackage</Title>
<Type>CatalogEntry</Type>
<Href>/episerverapi/commerce/entries/package</Href>
</ResourceLink>
</Entries>
</Node>
<Node>
<Code>Fashion</Code>
<ParentNodeCode>Departments</ParentNodeCode>
<Name>Fashion</Name>
<StartDate>2010-09-01T07:00:00Z</StartDate>
<EndDate>2020-10-01T07:00:00Z</EndDate>
<IsActive>true</IsActive>
<MetaClass>FashionStoreLandingNode</MetaClass>
<Catalog>Departmental Catalog</Catalog>
<SortOrder>1</SortOrder>
<ParentNode>
<Title>Departments</Title>
<Type>CatalogNode</Type>
<Href>/episerverapi/commerce/nodes/Departments</Href>
</ParentNode>
<MetaFields>
<MetaFieldProperty>
<Name>DisplayName</Name>
<Type>ShortString</Type>
<Data>
<MetaFieldData>
<Language>en</Language>
<Value>Fashion</Value>
</MetaFieldData>
</Data>
</MetaFieldProperty>
<MetaFieldProperty>
<Name>Info_Description</Name>
<Type>LongHtmlString</Type>
<Data>
<MetaFieldData>
<Language>en</Language>
<Value><p>Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper. Maecenas faucibus mollis interdum.</p></Value>
</MetaFieldData>
</Data>
</MetaFieldProperty>
<MetaFieldProperty>
<Name>Info_Promotional_Message</Name>
<Type>LongHtmlString</Type>
<Data>
<MetaFieldData>
<Language>en</Language>
<Value />
</MetaFieldData>
</Data>
</MetaFieldProperty>
</MetaFields>
<SeoInformation>
<SeoInfo>
<Title />
<Uri>Fashion.aspx</Uri>
<Description />
<Keywords />
<LanguageCode>en</LanguageCode>
</SeoInfo>
</SeoInformation>
<Assets />
<Children />
<Entries />
</Node>
</ArrayOfNode>
Get Node
/episerverapi/commerce/nodes/{node code}
By default this method gets all languages for the nodes and entries. If you want only one specific language, use the Accept-Language header.
Client Code Media Type JSON
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}").Result.Content.ReadAsStringAsync().Result
Response JSON
{
"Code" : "Departments",
"ParentNodeCode" : null,
"Name" : "Departments",
"StartDate" : "2010-09-01T07:00:00Z",
"EndDate" : "2020-10-01T07:00:00Z",
"IsActive" : true,
"MetaClass" : "DepartmentStoreLandingNode",
"Catalog" : "Departmental Catalog",
"SortOrder" : 1,
"ParentNode" : null,
"MetaFields" : [
{
"Name" : "DisplayName",
"Type" : "ShortString",
"Data" : [
{
"Language" : "en",
"Value" : "Departments"
}
]
},
{
"Name" : "Info_Description",
"Type" : "LongHtmlString",
"Data" : [
{
"Language" : "en",
"Value" : "Integer
posuere erat a ante venenatis dapibus posuere velit aliquet.
Vestibulum id ligula porta felis euismod semper.
Maecenas faucibus mollis interdum."
}
]
},
{
"Name" : "Info_Promotional_Message",
"Type" : "LongHtmlString",
"Data" : [
{
"Language" : "en",
"Value" : ""
}
]
}
],
"SeoInformation" : [
{
"Title" : "",
"Uri" : "Departments.aspx",
"UriSegment" : null,
"Description" : "",
"Keywords" : "",
"LanguageCode" : "en"
}
],
"Assets" : [],
"Children" : [
{
"Title" : "Fashion",
"Type" : "CatalogNode",
"Href" : "/episerverapi/commerce/nodes/Fashion"
},
{
"Title" : "Media",
"Type" : "CatalogNode",
"Href" : "/episerverapi/commerce/nodes/Media"
},
{
"Title" : "Automotive",
"Type" : "CatalogNode",
"Href" : "/episerverapi/commerce/nodes/Automotive"
},
{
"Title" : "Wine",
"Type" : "CatalogNode",
"Href" : "/episerverapi/commerce/nodes/Wine"
}
],
"Entries" : [
{
"Title" : "Bundle Grundle",
"Type" : "CatalogEntry",
"Href" : "/episerverapi/commerce/entries/bundle"
},
{
"Title" : "Package Smackage",
"Type" : "CatalogEntry",
"Href" : "/episerverapi/commerce/entries/package"
}
]
}
Client Code Media Type XML
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}").Result.Content.ReadAsStringAsync().Result
Response XML
<Node xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Code>Departments</Code>
<Name>Departments</Name>
<StartDate>2010-09-01T07:00:00Z</StartDate>
<EndDate>2020-10-01T07:00:00Z</EndDate>
<IsActive>true</IsActive>
<MetaClass>DepartmentStoreLandingNode</MetaClass>
<Catalog>Departmental Catalog</Catalog>
<SortOrder>1</SortOrder>
<MetaFields>
<MetaFieldProperty>
<Name>DisplayName</Name>
<Type>ShortString</Type>
<Data>
<MetaFieldData>
<Language>en</Language>
<Value>Departments</Value>
</MetaFieldData>
</Data>
</MetaFieldProperty>
<MetaFieldProperty>
<Name>Info_Description</Name>
<Type>LongHtmlString</Type>
<Data>
<MetaFieldData>
<Language>en</Language>
<Value><p>Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper. Maecenas faucibus mollis interdum.</p></Value>
</MetaFieldData>
</Data>
</MetaFieldProperty>
<MetaFieldProperty>
<Name>Info_Promotional_Message</Name>
<Type>LongHtmlString</Type>
<Data>
<MetaFieldData>
<Language>en</Language>
<Value />
</MetaFieldData>
</Data>
</MetaFieldProperty>
</MetaFields>
<SeoInformation>
<SeoInfo>
<Title />
<Uri>Departments.aspx</Uri>
<Description />
<Keywords />
<LanguageCode>en</LanguageCode>
</SeoInfo>
</SeoInformation>
<Assets />
<Children>
<ResourceLink>
<Title>Fashion</Title>
<Type>CatalogNode</Type>
<Href>/episerverapi/commerce/nodes/Fashion</Href>
</ResourceLink>
<ResourceLink>
<Title>Media</Title>
<Type>CatalogNode</Type>
<Href>/episerverapi/commerce/nodes/Media</Href>
</ResourceLink>
<ResourceLink>
<Title>Automotive</Title>
<Type>CatalogNode</Type>
<Href>/episerverapi/commerce/nodes/Automotive</Href>
</ResourceLink>
<ResourceLink>
<Title>Wine</Title>
<Type>CatalogNode</Type>
<Href>/episerverapi/commerce/nodes/Wine</Href>
</ResourceLink>
</Children>
<Entries>
<ResourceLink>
<Title>Bundle Grundle</Title>
<Type>CatalogEntry</Type>
<Href>/episerverapi/commerce/entries/bundle</Href>
</ResourceLink>
<ResourceLink>
<Title>Package Smackage</Title>
<Type>CatalogEntry</Type>
<Href>/episerverapi/commerce/entries/package</Href>
</ResourceLink>
</Entries>
</Node>
Post Node
/episerverapi/commerce/nodes
Client Code Media Type JSON
var model = new Node()
{
Code = "Node 2",
Catalog = "Departmental Catalog",
EndDate = DateTime.UtcNow.AddDays(100),
IsActive = true,
MetaClass = "CatalogNodeEx",
Name = "Test",
StartDate = DateTime.UtcNow,
ParentNodeCode = "Departments",
MetaFields = new List<MetaFieldProperty>()
{
new MetaFieldProperty()
{
Name = "DisplayName",
Type = "ShortString",
Data = new List<MetaFieldData>()
{
new MetaFieldData()
{
Language="en",
Value = "DisplayName"
}
}
}
},
SeoInformation = new List<SeoInfo>()
{
new SeoInfo()
{
Description = "description",
Keywords="",
LanguageCode = "en",
Title = "title",
Uri = "node 2",
UriSegment = "node 2"
}
}
};
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",
new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result
Response JSON
{
"Code" : "Node 2",
"ParentNodeCode" : "Departments",
"Name" : "Test",
"StartDate" : "2014-08-27T09:23:21.8685915Z",
"EndDate" : "2014-12-05T09:23:21.8675908Z",
"IsActive" : true,
"MetaClass" : "CatalogNodeEx",
"Catalog" : "Departmental Catalog",
"SortOrder" : 0,
"ParentNode" : null,
"MetaFields" : [
{
"Name" : "DisplayName",
"Type" : "ShortString",
"Data" : [
{
"Language" : "en",
"Value" : "DisplayName"
}
]
}
],
"SeoInformation" : [
{
"Title" : "title",
"Uri" : "node 2",
"UriSegment" : "node 2",
"Description" : "description",
"Keywords" : "",
"LanguageCode" : "en"
}
],
"Assets" : [],
"Children" : [],
"Entries" : []
}
Client Code Media Type XML
var model = new Node()
{
Code = "Node 2",
Catalog = "Departmental Catalog",
EndDate = DateTime.UtcNow.AddDays(100),
IsActive = true,
MetaClass = "CatalogNodeEx",
Name = "Test",
StartDate = DateTime.UtcNow,
ParentNodeCode = "Departments",
MetaFields = new List<MetaFieldProperty>()
{
new MetaFieldProperty()
{
Name = "DisplayName",
Type = "ShortString",
Data = new List<MetaFieldData>()
{
new MetaFieldData()
{
Language="en",
Value = "DisplayName"
}
}
}
},
SeoInformation = new List<SeoInfo>()
{
new SeoInfo()
{
Description = "description",
Keywords="",
LanguageCode = "en",
Title = "title",
Uri = "node 2",
UriSegment = "node 2"
}
}
};
var client = new HttpClient()
{
BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(Node));
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",
new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result
Response XML
<Node xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Code>Node 2</Code>
<ParentNodeCode>Departments</ParentNodeCode>
<Name>Test</Name>
<StartDate>2014-08-27T09:23:21.8685915Z</StartDate>
<EndDate>2014-12-05T09:23:21.8675908Z</EndDate>
<IsActive>true</IsActive>
<MetaClass>CatalogNodeEx</MetaClass>
<Catalog>Departmental Catalog</Catalog>
<SortOrder>0</SortOrder>
<MetaFields>
<MetaFieldProperty>
<Name>DisplayName</Name>
<Type>ShortString</Type>
<Data>
<MetaFieldData>
<Language>en</Language>
<Value>DisplayName</Value>
</MetaFieldData>
</Data>
</MetaFieldProperty>
</MetaFields>
<SeoInformation>
<SeoInfo>
<Title>title</Title>
<Uri>node 2</Uri>
<UriSegment>node 2</UriSegment>
<Description>description</Description>
<Keywords />
<LanguageCode>en</LanguageCode>
</SeoInfo>
</SeoInformation>
<Assets />
<Children />
<Entries />
</Node>
Put Node
/episerverapi/commerce/nodes/{node code}
Client Code Media Type JSON
var model = new Node()
{
Code = "Node 2",
Catalog = "Departmental Catalog",
EndDate = DateTime.UtcNow.AddDays(100),
IsActive = true,
MetaClass = "CatalogNodeEx",
Name = "Test",
StartDate = DateTime.UtcNow,
ParentNodeCode = "Departments",
MetaFields = new List<MetaFieldProperty>()
{
new MetaFieldProperty()
{
Name = "DisplayName",
Type = "ShortString",
Data = new List<MetaFieldData>()
{
new MetaFieldData()
{
Language="en",
Value = "DisplayName"
}
}
}
},
SeoInformation = new List<SeoInfo>()
{
new SeoInfo()
{
Description = "description",
Keywords="",
LanguageCode = "en",
Title = "title",
Uri = "node 2",
UriSegment = "node 2"
}
}
};
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}",
new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result
Response JSON
204 No Content
Client Code Media Type XML
var model = new Node()
{
Code = "Node 2",
Catalog = "Departmental Catalog",
EndDate = DateTime.UtcNow.AddDays(100),
IsActive = true,
MetaClass = "CatalogNodeEx",
Name = "Test",
StartDate = DateTime.UtcNow,
ParentNodeCode = "Departments",
MetaFields = new List<MetaFieldProperty>()
{
new MetaFieldProperty()
{
Name = "DisplayName",
Type = "ShortString",
Data = new List<MetaFieldData>()
{
new MetaFieldData()
{
Language="en",
Value = "DisplayName"
}
}
}
},
SeoInformation = new List<SeoInfo>()
{
new SeoInfo()
{
Description = "description",
Keywords="",
LanguageCode = "en",
Title = "title",
Uri = "node 2",
UriSegment = "node 2"
}
}
};
var client = new HttpClient()
{
BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(Node));
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}",
new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result
Response XML
204 No Content
Delete Node
/episerverapi/commerce/nodes/{node code}
Client Code Media Type JSON
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}").Result.Content.ReadAsStringAsync().Result
Response JSON
{
"Code" : "Node 2",
"ParentNodeCode" : "Departments",
"Name" : "Test",
"StartDate" : "2014-08-27T09:23:21.8685915Z",
"EndDate" : "2014-12-05T09:23:21.8675908Z",
"IsActive" : true,
"MetaClass" : "CatalogNodeEx",
"Catalog" : "Departmental Catalog",
"SortOrder" : 0,
"ParentNode" : null,
"MetaFields" : [
{
"Name" : "DisplayName",
"Type" : "ShortString",
"Data" : [
{
"Language" : "en",
"Value" : "DisplayName"
}
]
}
],
"SeoInformation" : [
{
"Title" : "title",
"Uri" : "node 2",
"UriSegment" : "node 2",
"Description" : "description",
"Keywords" : "",
"LanguageCode" : "en"
}
],
"Assets" : [],
"Children" : [],
"Entries" : []
}
Client Code Media Type XML
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}").Result.Content.ReadAsStringAsync().Result
Response XML
<Node xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Code>Node 2</Code>
<ParentNodeCode>Departments</ParentNodeCode>
<Name>Test</Name>
<StartDate>2014-08-27T09:23:21.8685915Z</StartDate>
<EndDate>2014-12-05T09:23:21.8675908Z</EndDate>
<IsActive>true</IsActive>
<MetaClass>CatalogNodeEx</MetaClass>
<Catalog>Departmental Catalog</Catalog>
<SortOrder>0</SortOrder>
<MetaFields>
<MetaFieldProperty>
<Name>DisplayName</Name>
<Type>ShortString</Type>
<Data>
<MetaFieldData>
<Language>en</Language>
<Value>DisplayName</Value>
</MetaFieldData>
</Data>
</MetaFieldProperty>
</MetaFields>
<SeoInformation>
<SeoInfo>
<Title>title</Title>
<Uri>node 2</Uri>
<UriSegment>node 2</UriSegment>
<Description>description</Description>
<Keywords />
<LanguageCode>en</LanguageCode>
</SeoInfo>
</SeoInformation>
<Assets />
<Children />
<Entries />
</Node>
Get common draft node [New in Service API 5.1.0]
By adding new endpoints as listed below, you can get common draft versions, create new common drafts, and update or delete existing drafts.
var client = new HttpClient()
{
BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
var result = client.GetAsync("/episerverapi/commerce/nodes/Node_1/commondraft/en").Result.Content.ReadAsStringAsync().Result;
{
"MetaFields" : [{
"Name" : "AnotherMultilanguageString",
"Type" : "ShortString","Data":""
},
{
"Name" : "DisplayName",
"Type" : "ShortString",
"Data" : "Node_1"
},
{
"Name" : "Epi_IsPublished",
"Type" : "Boolean","Data":""
},
{
"Name" : "Epi_StartPublish",
"Type" : "DateTime","Data":""
},
{
"Name" : "Epi_StopPublish",
"Type" : "DateTime",
"Data" : ""
}],
"SeoInformation" : {
"Title" : null,
"Uri" : "Node_1",
"UriSegment" : "node_1",
"Description" : "DESCRIPTION",
"Keywords" : null,
"LanguageCode" : "en"
},
"Code" : "Node_1",
"ParentNodeCode" : "TESTCATALOGTNODE",
"Name" : "Node_1",
"StartDate" : "2018-06-07T06:22:45.64Z",
"EndDate" : "2020-06-07T06:22:45.64Z",
"MetaClass" : "CatalogNodeEx",
"Catalog" : "TESTROOTCATALOG",
"SortOrder" : 0,
"ParentNode" : {
"Title" : "TEST CATALOG NODE",
"Type" : "CatalogNode",
"Href" : "/episerverapi/commerce/nodes/TESTCATALOGTNODE",
"Properties" : [{
"Name" : "Code",
"Value" : "TESTCATALOGTNODE"
}]
},
"Assets" : [{
"Title" : "http://localhost/globalassets/node.jpg/",
"Type" : "Asset",
"Href" : "/episerverapi/commerce/nodes/Node_1/assets/59/episerver.core.icontentimage",
"Properties" : null
}],
"Children" : [],
"Entries" : [{
"Title" : "Name 2",
"Type" : "CatalogEntry",
"Href" : "/episerverapi/commerce/entries/Code 2",
"Properties" : [{
"Name" : "Code",
"Value" : "Code 2"
}]
}]
}
var client = new HttpClient()
{
BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml"));
var result = client.GetAsync("/episerverapi/commerce/nodes/Node_1/commondraft/en").Result.Content.ReadAsStringAsync().Result;
<?xml version="1.0" encoding="UTF-8"?>
<DraftNode>
<Assets>
<element>
<Href>/episerverapi/commerce/nodes/Node_1/assets/24/episerver.core.icontentimage</Href>
<Properties null="true" />
<Title>http://localhost/globalassets/node.jpg/</Title>
<Type>Asset</Type>
</element>
</Assets>
<Catalog>TESTROOTCATALOG</Catalog>
<Children />
<Code>Node_1</Code>
<EndDate>2020-07-26T07:39:16.717Z</EndDate>
<Entries>
<element>
<Href>/episerverapi/commerce/entries/Code 2</Href>
<Properties>
<element>
<Name>Code</Name>
<Value>Code 2</Value>
</element>
</Properties>
<Title>Name 2</Title>
<Type>CatalogEntry</Type>
</element>
</Entries>
<MetaClass>CatalogNodeEx</MetaClass>
<MetaFields>
<element>
<Data />
<Name>AnotherMultilanguageString</Name>
<Type>ShortString</Type>
</element>
<element>
<Data>Node_1</Data>
<Name>DisplayName</Name>
<Type>ShortString</Type>
</element>
<element>
<Data />
<Name>IntegerMetaFieldName</Name>
<Type>Int</Type>
</element>
</MetaFields>
<Name>Node_1</Name>
<ParentNode>
<Href>/episerverapi/commerce/nodes/TESTCATALOGTNODE</Href>
<Properties>
<element>
<Name>Code</Name>
<Value>TESTCATALOGTNODE</Value>
</element>
</Properties>
<Title>TEST CATALOG NODE</Title>
<Type>CatalogNode</Type>
</ParentNode>
<ParentNodeCode>TESTCATALOGTNODE</ParentNodeCode>
<SeoInformation>
<Description>DESCRIPTION</Description>
<Keywords null="true" />
<Title null="true" />
<Uri>Node_1</Uri>
<UriSegment>node_1</UriSegment>
</SeoInformation>
<SortOrder>0</SortOrder>
<StartDate>2018-07-26T07:39:16.717Z</StartDate>
</DraftNode>
Post common draft node [New in Service API 5.1.0]
Note: We do not support creating common drafts for non-existing content. You can create a first draft version by using an endpoint for published content (without “commondraft”) and setting IsActive to “false”.
var parentNodeCode = "TESTCATALOGTNODE";
var _model = new DraftNode
{
Code = "Node 2",
Catalog = "TESTROOTCATALOG",
EndDate = DateTime.UtcNow.AddDays(100),
MetaClass = DefaultNodeMetaClassName,
Name = "Test",
StartDate = DateTime.UtcNow,
ParentNodeCode = parentNodeCode,
ParentNode = new Models.ResourceLink()
{
Title = "TEST CATALOG NODE",
Type = CatalogContentType.CatalogNode.ToString(),
Href = $"/episerverapi/commerce/nodes/{parentNodeCode}",
Properties = new List<Models.NameValue>()
{
new Models.NameValue()
{
Name = "Code",
Value = parentNodeCode
}
}
},
MetaFields = new List<DraftMetaFieldProperty>
{
new DraftMetaFieldProperty
{
Name = AnotherMultiLanguageStringMetaFieldName,
Type = MetaDataType.ShortString.ToString(),
Data = "Set with lang key EN for en"
},
new DraftMetaFieldProperty
{
Name = "DisplayName",
Type = MetaDataType.ShortString.ToString(),
Data = "DisplayName"
},
}
};
var json = JsonConvert.SerializeObject(_model);
var client = new HttpClient()
{
BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
var result = client.PostAsync("/episerverapi/commerce/nodes/commondraft/en",
new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result;
{
"MetaFields" : [
{
"Name" : "AnotherMultilanguageString",
"Type" : "ShortString",
"Data" : "Set with lang key EN for en"
},
{
"Name" : "DisplayName",
"Type" : "ShortString",
"Data" : "DisplayName"
}
],
"SeoInformation" : {
"Title" : null,
"Uri" : null,
"UriSegment" : null,
"Description" : null,
"Keywords" : null,
"LanguageCode" : null
},
"Code" : "Node 2",
"ParentNodeCode" : "TESTCATALOGTNODE",
"Name" : "Test",
"StartDate" : "2018-06-07T07:38:03.1773053Z",
"EndDate" : "2018-09-15T07:38:03.1773053Z",
"MetaClass" : "CatalogNodeEx",
"Catalog" : "TESTROOTCATALOG",
"SortOrder" : 0,
"ParentNode" : {
"Title" : "TEST CATALOG NODE",
"Type" : "CatalogNode",
"Href" : "/episerverapi/commerce/nodes/TESTCATALOGTNODE",
"Properties" : [
{
"Name" : "Code",
"Value" : "TESTCATALOGTNODE"
}
]
},
"Assets" : [],
"Children" : [],
"Entries" : []
}
var parentNodeCode = "TESTCATALOGTNODE";
var _model = new DraftNode
{
Code = "Node 2",
Catalog = "TESTROOTCATALOG",
EndDate = DateTime.UtcNow.AddDays(100),
MetaClass = DefaultNodeMetaClassName,
Name = "Test",
StartDate = DateTime.UtcNow,
ParentNodeCode = parentNodeCode,
ParentNode = new Models.ResourceLink()
{
Title = "TEST CATALOG NODE",
Type = CatalogContentType.CatalogNode.ToString(),
Href = $"/episerverapi/commerce/nodes/{parentNodeCode}",
Properties = new List<Models.NameValue>()
{
new Models.NameValue()
{
Name = "Code",
Value = parentNodeCode
}
}
},
MetaFields = new List<DraftMetaFieldProperty>
{
new DraftMetaFieldProperty
{
Name = "MultilanguageString",
Type = MetaDataType.ShortString.ToString(),
Data = "Set with lang key EN for en"
},
new DraftMetaFieldProperty
{
Name = "StringList",
Type = MetaDataType.LongString.ToString(),
Data = "[\"Item 1\",\"Item 2\"]"
},
new DraftMetaFieldProperty
{
Name = "IntList",
Type = MetaDataType.LongString.ToString(),
Data = $"[{10},{11},{12}]"
},
new DraftMetaFieldProperty
{
Name = "DoubleList",
Type = MetaDataType.LongString.ToString(),
Data = $"[{100.05.ToString(culture)},{100.06.ToString(culture)},{100.07.ToString(culture)},{100.08.ToString(culture)}]"
},
new DraftMetaFieldProperty
{
Name = "DateTimeList",
Type = MetaDataType.LongString.ToString(),
Data = $"[\"{DateTime.Now.ToString(culture)}\",\"{DateTime.Now.AddDays(1).ToString(culture)}\"]"
}
}
};
var client = new HttpClient()
{
BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(DraftNode));
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/commondraft/en",
new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result;
<?xml version="1.0" encoding="UTF-8"?>
<DraftNode>
<Assets />
<Catalog>TESTROOTCATALOG</Catalog>
<Children />
<Code>Custom node</Code>
<EndDate>2018-11-03T07:42:18.3292331Z</EndDate>
<Entries />
<MetaClass>CustomNodeMetadataClass</MetaClass>
<MetaFields>
<element>
<Data>Set with lang key EN for en</Data>
<Name>MultilanguageString</Name>
<Type>ShortString</Type>
</element>
<element>
<Data>
<element>Item 1</element>
<element>Item 2</element>
</Data>
<Name>StringList</Name>
<Type>LongString</Type>
</element>
<element>
<Data>
<element>10</element>
<element>11</element>
<element>12</element>
</Data>
<Name>IntList</Name>
<Type>LongString</Type>
</element>
<element>
<Data>
<element>100.05</element>
<element>100.06</element>
<element>100.07</element>
<element>100.08</element>
</Data>
<Name>DoubleList</Name>
<Type>LongString</Type>
</element>
<element>
<Data>
<element>7/26/2018 2:42:18 PM</element>
<element>7/27/2018 2:42:18 PM</element>
</Data>
<Name>DateTimeList</Name>
<Type>LongString</Type>
</element>
</MetaFields>
<Name>Test</Name>
<ParentNode>
<Href>/episerverapi/commerce/nodes/TESTCATALOGTNODE</Href>
<Properties>
<element>
<Name>Code</Name>
<Value>TESTCATALOGTNODE</Value>
</element>
</Properties>
<Title>TEST CATALOG NODE</Title>
<Type>CatalogNode</Type>
</ParentNode>
<ParentNodeCode>TESTCATALOGTNODE</ParentNodeCode>
<SeoInformation>
<Description null="true" />
<Keywords null="true" />
<Title null="true" />
<Uri null="true" />
<UriSegment null="true" />
</SeoInformation>
<SortOrder>0</SortOrder>
<StartDate>2018-07-26T07:42:18.3292331Z</StartDate>
</DraftNode>
Put common draft node [New in Service API 5.1.0]
Notes: If common draft content is in “Published” state, a new common draft version is created (same behavior as Post common draft). If common draft content is in "DelayedPublish/AwaitingApproval/CheckedIn" state, then updating content is skipped, and a Conflict status code (409) is returned.
var languageCode = "en";
_model = ServiceLocator.Instance.GetInstance<NodeModelFactory>()
.CreateDraftNodeModel(node, languageCode);
_model.Name = "Put Test";
_model.SeoInformation.Uri = "NewNodeUri";
var json = JsonConvert.SerializeObject(_model);
var client = new HttpClient()
{
BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
var result = client.PutAsync($"/episerverapi/commerce/nodes/Node_1/commondraft/{languageCode}",
new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result;
204 No Content
var languageCode = "en";
_model = ServiceLocator.Instance.GetInstance<NodeModelFactory>()
.CreateDraftNodeModel(node, languageCode);
_model.Name = "Put Test";
_model.SeoInformation.Uri = "NewNodeUri";
var client = new HttpClient()
{
BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(DraftNode));
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_1/commondraft/{languageCode}",
new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result;
204 No Content
Delete common draft node [New in Service API 5.1.0]
var client = new HttpClient()
{
BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
var result = client.DeleteAsync("/episerverapi/commerce/nodes/Node_1/commondraft/en").Result.Content.ReadAsStringAsync().Result;
200 OK
var client = new HttpClient()
{
BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthorizationHeaderValue("Bearer", token.AccessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml"));
var result = client.DeleteAsync("/episerverapi/commerce/nodes/Node_1/commondraft/en").Result.Content.ReadAsStringAsync().Result;
200 OK
Related topics
Last updated: Aug 14, 2017