HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Catalog nodes

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

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; }
  }

Published catalog nodes

Get all nodes

By default this method gets all languages for the catalog nodes and entries. If you want only one specific language, use the Accept-Language header.

GETget/episerverapi/commerce/catalog/{catalogName}/nodesGet all nodes

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/catalog/{catalogName}/nodes").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").Result.Content.ReadAsStringAsync().Result

Response

<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 a specific node

By default this method gets all languages for the catalog nodes and entries. If you want only one specific language, use the Accept-Language header.

GETget/episerverapi/commerce/nodes/{nodeCode}Get a specific node

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

Response

<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>

Create node

POSTpost/episerverapi/commerce/nodesCreate node

JSON response type

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

XML response type

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

<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>

Update node

PUTput/episerverapi/commerce/nodes/{nodeCode}Update node

JSON response type

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

XML response type

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

204 No Content

Delete node

DELETEdelete/episerverapi/commerce/nodes/{nodeCode}Delete node

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

Response

<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>

Common draft catalog nodes [New in Service API 5.1.0]

By adding new endpoints as listed below, you can get common draft versions of catalog nodes, create new common node drafts, and update or delete existing node drafts.

Get common draft node

GETget/episerverapi/commerce/nodes/{nodeCode}/commondraft/{lang}et common draft node

JSON response type

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;

XML response type

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;

Response

<?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>

Create common draft node

📘

Note

The Service API does 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”.

POSTpost/episerverapi/commerce/nodes/commondraft/{lang}Create common draft node

JSON response type

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;

XML response type

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;

Response

<?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>

Update common draft node 

📘

Note

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.

PUTput/episerverapi/commerce/nodes/{nodeCode}/commondraft/{lang}Update common draft node

JSON response type

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;

XML response type

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;

Response

204 No Content

Delete common draft node

DELETEdelete/episerverapi/commerce/nodes/{nodeCode}/commondraft/{lang}Delete common draft node

JSON response type

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;

XML response type

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;

Response

200 OK