Search code examples
c#.netebay-api

Why does GetCategoriesCall return 0 categories?


I'm trying to get all root categories for eBay Germany using the eBay .Net SDK. I have this code:

var rootCategoriesCall = new GetCategoriesCall(apiContext);
rootCategoriesCall.Site = SiteCodeType.Germany;
rootCategoriesCall.LevelLimit = 1;
var categories = rootCategoriesCall.GetCategories().Cast<CategoryType>();

The call appears to be executed (there is the usual delay that accompanies eBay API calls) and it does not throw an error, yet I get 0 categories. Does anyone know what might be causing this behavior and how to fix it?

Note that I use a Sandbox token. As for the rootCategoriesCall.LevelLimit = 1; line. This site was suggesting it as a way of getting only the root categories.

P.S. I also tried setting CategorySiteID instead of Site and not setting it at all (it defaults to eBay US), but the result was the same.


Solution

  • I'm not entirely sure about why it is required, but it appears that I explicitly need to set DetailLevel. If I change my call to:

    var rootCategoriesCall = new GetCategoriesCall(apiContext);
    rootCategoriesCall.Site = SiteCodeType.Germany;
    rootCategoriesCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
    rootCategoriesCall.LevelLimit = 1;
    var categories = rootCategoriesCall.GetCategories().Cast<CategoryType>();
    

    I do get the root categories.