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

Catalog item assets

Recommended reading 

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

In this topic

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/episerverapi/commerce/entries/{entryCode}/assets

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

XML response type

Get a specific entry asset

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

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

XML response type

Create entry asset

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

JSON response type

C# code sample

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

Update entry asset

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

JSON response type

C# code sample

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

Delete entry asset

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

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

XML response type

Node assets

Get all node assets

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

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

XML response type

Get a specific node asset

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

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

XML response type

Create node asset

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

JSON response type

C# code sample

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

Update node asset

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

JSON response type

C# code sample

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

Delete node asset

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

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

XML response type

Related topics

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

Last updated: Oct 20, 2016

Recommended reading