question

rubart*de avatar image
0 Likes"
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 com.ebay.sdk.call.GetCategoriesCall.stringFromSiteCodeType(GetCategoriesCall.java:356) at com.ebay.sdk.call.GetCategoriesCall.getCategories(GetCategoriesCall.java:147) at com.channelpilot.tools.ebay.UpdateEBaySettings.getCategories(UpdateEBaySettings.java:1531) at com.channelpilot.tools.ebay.UpdateEBaySettings.update(UpdateEBaySettings.java:1637) at com.channelpilot.tools.Importer.callImporter(Importer.java:93) at com.channelpilot.tools.Importer.main(Importer.java:54) 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 ebay.ru
10 |600 characters needed characters left characters exceeded

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

1 Answer

· Write an Answer
zhuowei.developersupport@ebay.com avatar image
0 Likes"
zhuowei.developersupport@ebay.com 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 = " https://api.ebay.com/wsapi"; 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 characters needed characters left characters exceeded

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.