rubart*de avatar image
rubart*de asked

NPE while getting categories for sideId Russia

Hello, I'm using java sdk version 921 and trying to get all categories for siteId Russia using API getCategories() method call. However I get the following NPE: java.lang.NullPointerException at com.ebay.sdk.SiteIDUtil.toNumericalID(Unknown Source) at at at at at at I can get categories for other countries though. Does anybody know if there is another way to get categories for Russia or how to overcome this exception? Thank you. Best, Anastasiya
categoriesgetcategoriesnullpointerexceptionrussia ru
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· avatar image
0 Likes" answered
Hi rubart*de, Thank you for reporting the issue. We will look into it. Meanwhile, you can retrieve Russia category information via SDK without using the GetCategoriesCall wrapper class. Here is the code: public class GetCategories_RU { static String TOKEN = "YOUR TOKEN"; static String APISERVERURL = ""; public static void main(String[] args) { DetailLevelCodeType[] detailLevel = new DetailLevelCodeType[]{ DetailLevelCodeType.RETURN_ALL }; //Initialize eBay ApiContext object ApiContext apiContext = new ApiContext(); //Setting the context ApiCredential cred = apiContext.getApiCredential(); apiContext.setSite( SiteCodeType.US); cred.seteBayToken(TOKEN); //set Api Server Url apiContext.setApiServerUrl(APISERVERURL); // Create a raw ApiCall object. ApiCall api = new ApiCall(apiContext); api.setDetailLevel(detailLevel); // Create a raw API request object and config it. GetCategoriesRequestType request = new GetCategoriesRequestType(); try { request.setLevelLimit(4); request.setViewAllNodes(true); request.setCategorySiteID("215"); // Execute the API call. GetCategoriesResponseType response = (GetCategoriesResponseType) api.execute(request); CategoryArrayType catArr = response.getCategoryArray(); CategoryType[] cats = catArr.getCategory(); System.out.println(" apiContext.getRequestXml() >>>>> " + apiContext.getRequestXml()); System.out.println("apiContext.getResponseXml() >>>>> " + apiContext.getResponseXml()); for (CategoryType cate : cats) { if (cate.getCategoryID().compareTo(cate.getCategoryParentID(0)) == 0) { System.out.println(" CategoryID=" + cate.getCategoryID() + " | CategoryName=" + cate.getCategoryName() + " | CategoryParentID= " + cate.getCategoryParentID(0) + " | CategoryLevel " + cate.getCategoryLevel()); } } } catch (Exception e) { //handle exception here } } } Best Regards,
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.