HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityLog In

Catalog item assets

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

Example models

[Serializable]
public class ItemAsset
  {
    public string CatalogNodeCode { get; set; }
    public string CatalogEntryCode { get; set; }
    public string AssetKey { get; set; }
    public string AssetType { get; set; }
    public string GroupName { get; set; }
    public int SortOrder { get; set; }
  }

Entry assets

Get all entry assets

GET

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

Get all entry assets

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/entries/{entry code}/assets").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/entries/{entry code}/assets").Result.Content.ReadAsStringAsync().Result

Response

<ArrayOfItemAsset xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ItemAsset>
    <CatalogEntryCode>Jackets-Blazers-Wrap</CatalogEntryCode>
    <AssetKey>fd761c1d-5692-48b6-b90a-1ddf4c7c5eb9</AssetKey>
    <AssetType>episerver.core.icontentimage</AssetType>
    <GroupName>large</GroupName>
    <SortOrder>45</SortOrder>
  </ItemAsset>
</ArrayOfItemAsset>

Get a specific entry asset

GET

get/episerverapi/commerce/entries/{entryCode}/assets/{assetKey}/{assetType}

Get a specific entry asset

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/entries/{entry code}/assets/{assetKey}/{assetType}").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/entries/{entry code}/assets/{assetKey}/{assetType}").Result.Content.ReadAsStringAsync().Result

Response

<ItemAsset xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <CatalogEntryCode>Jackets-Blazers-Wrap</CatalogEntryCode>
  <AssetKey>fd761c1d-5692-48b6-b90a-1ddf4c7c5eb9</AssetKey>
  <AssetType>episerver.core.icontentimage</AssetType>
  <GroupName>large</GroupName>
  <SortOrder>45</SortOrder>
</ItemAsset>

Create entry asset

POST

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

Create entry asset

JSON response type

var model = new ItemAsset() 
  {
    CatalogEntryCode = "Jackets-Blazers-Wrap",
    AssetKey = "fd761c1d-5692-48b6-b90a-1ddf4c7c5eb9",
    AssetType = "episerver.core.icontentimage",
    SortOrder = 45,
    GroupName = "large"
  };
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}/assets",
  new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

XML response type

var model = new ItemAsset()
  {
    CatalogEntryCode = "Jackets-Blazers-Wrap",
    AssetKey = "fd761c1d-5692-48b6-b90a-1ddf4c7c5eb9",
    AssetType = "episerver.core.icontentimage",
    SortOrder = 45,
    GroupName = "large"
  };
var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(ItemAsset));
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/entries/{entry code}/assets",
  new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result

Response

<ItemAsset xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <CatalogEntryCode>Jackets-Blazers-Wrap</CatalogEntryCode>
  <AssetKey>fd761c1d-5692-48b6-b90a-1ddf4c7c5eb9</AssetKey>
  <AssetType>episerver.core.icontentimage</AssetType>
  <GroupName>large</GroupName>
  <SortOrder>45</SortOrder>
</ItemAsset>

Update entry asset

PUT

put/episerverapi/commerce/entries/{entryCode}/assets/{assetKey}/{assetType}

Update entry asset

JSON response type

var model = new ItemAsset()
  {
    CatalogEntryCode = "Jackets-Blazers-Wrap",
    AssetKey = "fd761c1d-5692-48b6-b90a-1ddf4c7c5eb9",
    AssetType = "episerver.core.icontentimage",
    SortOrder = 45,
    GroupName = "large"
  };

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}/assets/{assetKey}/{assetType}",
  new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

XML response type

var model = new ItemAsset()
  {
    CatalogEntryCode = "Jackets-Blazers-Wrap",
    AssetKey = "fd761c1d-5692-48b6-b90a-1ddf4c7c5eb9",
    AssetType = "episerver.core.icontentimage",
    SortOrder = 45,
    GroupName = "large"
  };
var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(ItemAsset));
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/entries/{entry code}/assets/{assetKey}/{assetType}",
  new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result

Response

204 No Content

Delete entry asset

DELETE

delete/episerverapi/commerce/entries/{entryCode}/assets/{assetKey}/{assetType}

Delete entry asset

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/entries/{entry code}/assets/{assetKey}/{assetType}").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/entries/{entry code}/assets/{assetKey}/{assetType}").Result.Content.ReadAsStringAsync().Result

Response

<ItemAsset xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <CatalogEntryCode>Jackets-Blazers-Wrap</CatalogEntryCode>
  <AssetKey>fd761c1d-5692-48b6-b90a-1ddf4c7c5eb9</AssetKey>
  <AssetType>episerver.core.icontentimage</AssetType>
  <GroupName>large</GroupName>
  <SortOrder>45</SortOrder>
</ItemAsset>

Node assets

Get all node assets

GET

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

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

Response

<ArrayOfItemAsset xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ItemAsset>
    <CatalogNodeCode>Fashion</CatalogNodeCode>
    <AssetKey>ed6fc3d7-091f-4e84-b1f6-49b56e7b5146</AssetKey>
    <AssetType>episerver.core.icontentimage</AssetType>
    <GroupName>large</GroupName>
    <SortOrder>45</SortOrder>
  </ItemAsset>
  <ItemAsset>
    <CatalogNodeCode>Fashion</CatalogNodeCode>
    <AssetKey>fe642158-e9cf-43c9-a70d-42cd75903dc6</AssetKey>
    <AssetType>episerver.core.icontentimage</AssetType>
    <GroupName>small</GroupName>
    <SortOrder>0</SortOrder>
  </ItemAsset>
</ArrayOfItemAsset>

Get a specific node asset

GET

get/episerverapi/commerce/nodes/{nodeCode}/assets/{assetKey}/{assetType}

Get a specific node asset

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}/assets/{assetKey}/{assetType}").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}/assets/{assetKey}/{assetType}").Result.Content.ReadAsStringAsync().Result

Response

<ItemAsset xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <CatalogNodeCode>Fashion</CatalogNodeCode>
  <AssetKey>ed6fc3d7-091f-4e84-b1f6-49b56e7b5146</AssetKey>
  <AssetType>episerver.core.icontentimage</AssetType>
  <GroupName>large</GroupName>
  <SortOrder>45</SortOrder>
</ItemAsset>

Create node asset

POST

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

Create node asset

JSON response type

var model = new ItemAsset()
  {
    CatalogNodeCode = "Fashion",
    AssetKey = "ed6fc3d7-091f-4e84-b1f6-49b56e7b5146",
    AssetType = "episerver.core.icontentimage",
    SortOrder = 45,
    GroupName = "large"
  };
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}/assets",
  new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

XML response type

var model = new ItemAsset()
  {
    CatalogNodeCode = "Fashion",
    AssetKey = "ed6fc3d7-091f-4e84-b1f6-49b56e7b5146",
    AssetType = "episerver.core.icontentimage",
    SortOrder = 45,
    GroupName = "large"
  };
var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(ItemAsset));
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}/assets",
  new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result

Response

<ItemAsset xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <CatalogNodeCode>Fashion</CatalogNodeCode>
  <AssetKey>ed6fc3d7-091f-4e84-b1f6-49b56e7b5146</AssetKey>
  <AssetType>episerver.core.icontentimage</AssetType>
  <GroupName>large</GroupName>
  <SortOrder>45</SortOrder>
</ItemAsset>

Update node asset

PUT

put/episerverapi/commerce/nodes/{nodeCode}/assets/{assetKey}/{assetType}

Update node asset

JSON response type

var model = new ItemAsset()
  {
    CatalogNodeCode = "Fashion",
    AssetKey = "ed6fc3d7-091f-4e84-b1f6-49b56e7b5146",
    AssetType = "episerver.core.icontentimage",
    SortOrder = 45,
    GroupName = "large"
  };
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}/assets/{assetKey}/{assetType}",
  new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

XML response type

var model = new ItemAsset()
  {
    CatalogNodeCode = "Fashion",
    AssetKey = "ed6fc3d7-091f-4e84-b1f6-49b56e7b5146",
    AssetType = "episerver.core.icontentimage",
    SortOrder = 45,    
    GroupName = "large"
  };
var client = new HttpClient()
  {
    BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
  };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(ItemAsset));
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}/assets/{assetKey}/{assetType}",
  new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result

Response

200 No Content

Delete node asset

DELETE

delete/episerverapi/commerce/nodes/{nodeCode}/assets/{assetKey}/{assetType}

Delete node asset

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}/assets/{assetKey}/{assetType}").Result.Content.ReadAsStringAsync().Result

XML response type

ar 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}/assets/{assetKey}/{assetType}").Result.Content.ReadAsStringAsync().Result

Response

<ItemAsset xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <CatalogNodeCode>Fashion</CatalogNodeCode>
  <AssetKey>ed6fc3d7-091f-4e84-b1f6-49b56e7b5146</AssetKey>
  <AssetType>episerver.core.icontentimage</AssetType>
  <GroupName>large</GroupName>
  <SortOrder>45</SortOrder>
</ItemAsset>

Did this page help you?