GetStore returns the store categories hierarchically. Since the categories can be nested very differently from level to level, you essentially need to use recursive logic to retrieve all of them.
Detailed Description
Here is a sample C# code using the .NET SDK to retrieve all the store categories.
namespaceNETSDKSample
{
publicclass SDKSample
{
privatevoid GetStore()
{ //set your credentials for the call
ApiContext context = newApiContext();
context.ApiCredential.ApiAccount.Developer = "devID";
context.ApiCredential.ApiAccount.Application = "appID";
context.ApiCredential.ApiAccount.Certificate = "certID";
context.ApiCredential.eBayToken = "token";
// Set the URL
context.SoapApiServerUrl = "https://api.sandbox.ebay.com/wsapi";
// Set logging
context.ApiLogManager = new ApiLogManager();
context.ApiLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("Messages.log", true, true, true));
context.ApiLogManager.EnableLogging = true;
// Set the version
context.Version = "571";
//create call
GetStoreCall call = newGetStoreCall(context);
//get just the store categories
call.CategoryStructureOnly = true;
call.Execute();
//iterate through the top level categories
foreach (StoreCustomCategoryType cat in call.Store.CustomCategories)
{
GetChildCategories(cat);
}
}
privatevoid GetChildCategories(StoreCustomCategoryType cat)
{
//get the category name, ID and whether it is a leaf
long id = cat.CategoryID;
string name = cat.Name;
bool leaf = (cat.ChildCategory.Count == 0);
Console.WriteLine("id = " + id + " name = " + name + " leaf= " + leaf);
//condition to end the recursion
if (leaf)
{
return;
}
//continue the recursion for each of the child categories
foreach (StoreCustomCategoryType childcat in cat.ChildCategory)
{
GetChildCategories(childcat);
}
}