Hide menu Last updated: Oct 20 2016
Area: Episerver Service API Applies to versions: 1 and higher

Catalog RESTful operations

This topic describes how to work with catalogs and RESTful operations in the Episerver service API, when defining catalog integration services for Episerver Commerce. See Catalog service for information about using the service integration for catalogs.

Table of contents

Example models

C#
[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 CatalogLanguage
{
		public String LanguageCode { get; set; }
		public String Catalog { get; set; }
		public String UriSegment { get; set; }
}
[Serializable]
public class Catalog
{
		public Guid ApplicationId { get; set; }
		public DateTime EndDate { get; set; }
		public DateTime StartDate { get; set; }
		public bool IsActive { get; set; }
		public bool IsPrimary { get; set; }
		public String Owner { get; set; }
		public int SortOrder { get; set; }
		public String Name { get; set; }
		public String DefaultCurrency { get; set; }
		public String DefaultLanguage { get; set; }
		public String WeightBase { get; set; }
		public List<CatalogLanguage> Languages { get; set; }
		public List<ResourceLink> Nodes { get; set; }
		public List<ResourceLink> Entries { get; set; }
}
Get all catalogs /episerverapi/commerce/catalogs

Client Code Media Type Json

C#
var client = new HttpClient()
{
	BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);		
var result = client.GetAsync("/episerverapi/commerce/catalogs").Result.Content.ReadAsStringAsync().Result

Response Json

Json
[
  {
    "ApplicationId": "b60ed82e-95b4-4f8b-ad43-2ce99f3b9470",
    "EndDate": "2022-01-16T05:51:00Z",
    "StartDate": "2012-01-16T05:51:00Z",
    "IsActive": true,
    "IsPrimary": false,
    "Owner": "",
    "SortOrder": 0,
    "Name": "Departmental Catalog",
    "DefaultCurrency": "usd",
    "DefaultLanguage": "en",
    "WeightBase": "lbs",
    "Languages": [
      {
        "LanguageCode": "en",
        "Catalog": "Departmental Catalog",
        "UriSegment": "departmental-catalog"
      }
    ],
    "Nodes": [
      {
        "Title": "Departments",
        "Type": "CatalogNode",
        "Href": "/episerverapi/commerce/nodes/Departments"
      }
    ],
    "Entries": []
  },
  {
    "ApplicationId": "b60ed82e-95b4-4f8b-ad43-2ce99f3b9470",
    "EndDate": "2024-08-13T11:41:00Z",
    "StartDate": "2014-08-13T11:41:00Z",
    "IsActive": true,
    "IsPrimary": false,
    "Owner": "",
    "SortOrder": 0,
    "Name": "TestCatalog",
    "DefaultCurrency": "usd",
    "DefaultLanguage": "en",
    "WeightBase": "lbs",
    "Languages": [
      {
        "LanguageCode": "en",
        "Catalog": "TestCatalog",
        "UriSegment": "testcatalog"
      }
    ],
    "Nodes": [
      {
        "Title": "Node 1",
        "Type": "CatalogNode",
        "Href": "/episerverapi/commerce/nodes/Node 1"
      }
    ],
    "Entries": []
  }
]

Client Code Media Type XML

C#
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/catalogs").Result.Content.ReadAsStringAsync().Result

Response XML

XML
<ArrayOfCatalog xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Catalog>
    <ApplicationId>b60ed82e-95b4-4f8b-ad43-2ce99f3b9470</ApplicationId>
    <EndDate>2022-01-16T05:51:00Z</EndDate>
    <StartDate>2012-01-16T05:51:00Z</StartDate>
    <IsActive>true</IsActive>
    <IsPrimary>false</IsPrimary>
    <Owner />
    <SortOrder>0</SortOrder>
    <Name>Departmental Catalog</Name>
    <DefaultCurrency>usd</DefaultCurrency>
    <DefaultLanguage>en</DefaultLanguage>
    <WeightBase>lbs</WeightBase>
    <Languages>
      <CatalogLanguage>
        <LanguageCode>en</LanguageCode>
        <Catalog>Departmental Catalog</Catalog>
        <UriSegment>departmental-catalog</UriSegment>
      </CatalogLanguage>
    </Languages>
    <Nodes>
      <ResourceLink>
        <Title>Departments</Title>
        <Type>CatalogNode</Type>
        <Href>/episerverapi/commerce/nodes/Departments</Href>
      </ResourceLink>
    </Nodes>
    <Entries />
  </Catalog>
  <Catalog>
    <ApplicationId>b60ed82e-95b4-4f8b-ad43-2ce99f3b9470</ApplicationId>
    <EndDate>2024-08-13T11:41:00Z</EndDate>
    <StartDate>2014-08-13T11:41:00Z</StartDate>
    <IsActive>true</IsActive>
    <IsPrimary>false</IsPrimary>
    <Owner />
    <SortOrder>0</SortOrder>
    <Name>TestCatalog</Name>
    <DefaultCurrency>usd</DefaultCurrency>
    <DefaultLanguage>en</DefaultLanguage>
    <WeightBase>lbs</WeightBase>
    <Languages>
      <CatalogLanguage>
        <LanguageCode>en</LanguageCode>
        <Catalog>TestCatalog</Catalog>
        <UriSegment>testcatalog</UriSegment>
      </CatalogLanguage>
    </Languages>
    <Nodes>
      <ResourceLink>
        <Title>Node 1</Title>
        <Type>CatalogNode</Type>
        <Href>/episerverapi/commerce/nodes/Node 1</Href>
      </ResourceLink>
    </Nodes>
    <Entries />
  </Catalog>
</ArrayOfCatalog>

Get Catalog /episerverapi/commerce/catalogs/{name}

Client Code Media Type Json

C#
var client = new HttpClient()
{
	BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);		
var result = client.GetAsync("/episerverapi/commerce/catalogs/{name}").Result.Content.ReadAsStringAsync().Result

Response Json

Json
{
  "ApplicationId": "b60ed82e-95b4-4f8b-ad43-2ce99f3b9470",
  "EndDate": "2022-01-16T05:51:00Z",
  "StartDate": "2012-01-16T05:51:00Z",
  "IsActive": true,
  "IsPrimary": false,
  "Owner": "",
  "SortOrder": 0,
  "Name": "Departmental Catalog",
  "DefaultCurrency": "usd",
  "DefaultLanguage": "en",
  "WeightBase": "lbs",
  "Languages": [
    {
      "LanguageCode": "en",
      "Catalog": "Departmental Catalog",
      "UriSegment": "departmental-catalog"
    }
  ],
  "Nodes": [
    {
      "Title": "Departments",
      "Type": "CatalogNode",
      "Href": "/episerverapi/commerce/nodes/Departments"
    }
  ],
  "Entries": []
}

Client Code Media Type XML

C#
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/catalogs/{name}).Result.Content.ReadAsStringAsync().Result

Response XML

XML
<Catalog xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ApplicationId>b60ed82e-95b4-4f8b-ad43-2ce99f3b9470</ApplicationId>
  <EndDate>2022-01-16T05:51:00Z</EndDate>
  <StartDate>2012-01-16T05:51:00Z</StartDate>
  <IsActive>true</IsActive>
  <IsPrimary>false</IsPrimary>
  <Owner />
  <SortOrder>0</SortOrder>
  <Name>Departmental Catalog</Name>
  <DefaultCurrency>usd</DefaultCurrency>
  <DefaultLanguage>en</DefaultLanguage>
  <WeightBase>lbs</WeightBase>
  <Languages>
    <CatalogLanguage>
      <LanguageCode>en</LanguageCode>
      <Catalog>Departmental Catalog</Catalog>
      <UriSegment>departmental-catalog</UriSegment>
    </CatalogLanguage>
  </Languages>
  <Nodes>
    <ResourceLink>
      <Title>Departments</Title>
      <Type>CatalogNode</Type>
      <Href>/episerverapi/commerce/nodes/Departments</Href>
    </ResourceLink>
  </Nodes>
  <Entries />
</Catalog>

Post Catalog /episerverapi/commerce/catalogs

Client Code Media Type Json

C#
var model = new Catalog()
{
		DefaultCurrency = "usd",
		DefaultLanguage = "en",
		EndDate = DateTime.UtcNow.AddYears(1),
		IsActive = true,
		IsPrimary = true,
		Languages = new List<CatalogLanguage>()
		{
				new CatalogLanguage()
				{
						Catalog = "Test Post",
						LanguageCode = "en",
						UriSegment = "Test Post"
				}
		},
		Name = "Test Post",
		StartDate = DateTime.UtcNow,
		WeightBase = "lbs"
};
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/catalogs", new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

Response Json

Json
{
  "ApplicationId": "b60ed82e-95b4-4f8b-ad43-2ce99f3b9470",
  "EndDate": "2015-08-27T15:17:51.6903028Z",
  "StartDate": "2014-08-27T15:17:51.6903028Z",
  "IsActive": true,
  "IsPrimary": true,
  "Owner": null,
  "SortOrder": 0,
  "Name": "Test Post",
  "DefaultCurrency": "usd",
  "DefaultLanguage": "en",
  "WeightBase": "lbs",
  "Languages": [
    {
      "LanguageCode": "en",
      "Catalog": "Test Post",
      "UriSegment": "Test Post"
    }
  ],
  "Nodes": null,
  "Entries": null
}

Client Code Media Type XML

C#
var model = new Catalog()
{
		DefaultCurrency = "usd",
		DefaultLanguage = "en",
		EndDate = DateTime.UtcNow.AddYears(1),
		IsActive = true,
		IsPrimary = true,
		Languages = new List<CatalogLanguage>()
		{
				new CatalogLanguage()
				{
						Catalog = "Test Post",
						LanguageCode = "en",
						UriSegment = "Test Post"
				}
		},
		Name = "Test Post",
		StartDate = DateTime.UtcNow,
		WeightBase = "lbs"
};
var client = new HttpClient()
{
	BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(Catalog));
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/catalogs", new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result

Response XML

XML
<Catalog xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ApplicationId>b60ed82e-95b4-4f8b-ad43-2ce99f3b9470</ApplicationId>
  <EndDate>2015-08-27T15:17:51.6903028Z</EndDate>
  <StartDate>2014-08-27T15:17:51.6903028Z</StartDate>
  <IsActive>true</IsActive>
  <IsPrimary>true</IsPrimary>
  <SortOrder>0</SortOrder>
  <Name>Test Post</Name>
  <DefaultCurrency>usd</DefaultCurrency>
  <DefaultLanguage>en</DefaultLanguage>
  <WeightBase>lbs</WeightBase>
  <Languages>
    <CatalogLanguage>
      <LanguageCode>en</LanguageCode>
      <Catalog>Test Post</Catalog>
      <UriSegment>Test Post</UriSegment>
    </CatalogLanguage>
  </Languages>
  <Nodes />
  <Entries />
</Catalog>

Put Catalog /episerverapi/commerce/catalogs/{name}

Client Code Media Type Json

C#
var model = new Catalog()
{
		DefaultCurrency = "usd",
		DefaultLanguage = "en",
		EndDate = DateTime.UtcNow.AddYears(1),
		IsActive = true,
		IsPrimary = true,
		Languages = new List<CatalogLanguage>()
		{
				new CatalogLanguage()
				{
						Catalog = "Test Post",
						LanguageCode = "en",
						UriSegment = "Test Post"
				}
		},
		Name = "Test Post",
		StartDate = DateTime.UtcNow,
		WeightBase = "lbs"
};
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/catalogs/{name}", new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result

Response Json

Json
200 No Content

Client Code Media Type XML

C#
var model = new Catalog()
{
		DefaultCurrency = "usd",
		DefaultLanguage = "en",
		EndDate = DateTime.UtcNow.AddYears(1),
		IsActive = true,
		IsPrimary = true,
		Languages = new List<CatalogLanguage>()
		{
				new CatalogLanguage()
				{
						Catalog = "Test Post",
						LanguageCode = "en",
						UriSegment = "Test Post"
				}
		},
		Name = "Test Post",
		StartDate = DateTime.UtcNow,
		WeightBase = "lbs"
};
var client = new HttpClient()
{
	BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var serializer = new XmlSerializer(typeof(Catalog));
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/catalogs/{name}", new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result

Response XML

XML
200 No Content

Delete Catalog /episerverapi/commerce/catalogs/{name}

Client Code Media Type Json

C#
var client = new HttpClient()
{
	BaseAddress = new Uri(ConfigurationManager.AppSettings["integrationUrl"])
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);		
var result = client.DeleteAsync("/episerverapi/commerce/catalogs/{name}").Result.Content.ReadAsStringAsync().Result

Response Json

Json
{
  "ApplicationId": "b60ed82e-95b4-4f8b-ad43-2ce99f3b9470",
  "EndDate": "2015-08-27T15:17:51.6903028Z",
  "StartDate": "2014-08-27T15:17:51.6903028Z",
  "IsActive": true,
  "IsPrimary": true,
  "Owner": null,
  "SortOrder": 0,
  "Name": "Test Post",
  "DefaultCurrency": "usd",
  "DefaultLanguage": "en",
  "WeightBase": "lbs",
  "Languages": [
    {
      "LanguageCode": "en",
      "Catalog": "Test Post",
      "UriSegment": "Test Post"
    }
  ],
  "Nodes": null,
  "Entries": null
}

Client Code Media Type XML

C#
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/catalogs/{name}").Result.Content.ReadAsStringAsync().Result

Response XML

XML
<Catalog xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ApplicationId>b60ed82e-95b4-4f8b-ad43-2ce99f3b9470</ApplicationId>
  <EndDate>2015-08-27T15:17:51.6903028Z</EndDate>
  <StartDate>2014-08-27T15:17:51.6903028Z</StartDate>
  <IsActive>true</IsActive>
  <IsPrimary>true</IsPrimary>
  <SortOrder>0</SortOrder>
  <Name>Test Post</Name>
  <DefaultCurrency>usd</DefaultCurrency>
  <DefaultLanguage>en</DefaultLanguage>
  <WeightBase>lbs</WeightBase>
  <Languages>
    <CatalogLanguage>
      <LanguageCode>en</LanguageCode>
      <Catalog>Test Post</Catalog>
      <UriSegment>Test Post</UriSegment>
    </CatalogLanguage>
  </Languages>
  <Nodes />
  <Entries />
</Catalog>

Comments