question

chibierutonia avatar image
0 Likes"
chibierutonia asked

Can't get any private data from API call eg. user sold list

**Hi, I'm developing a small ebay app that gathers data about specified user's sold items, their id, buyers' contact data etc. However when I make an API call to get, for example, user's sold list or watch list, I only get null lists. This happens only when trying to get "private" ebay data - in other words the ones when I need to input my user token (which, along with other data, like devID, appID and certID, is loaded from config.properties). With "public" data, such as ebay server time or some user data that can be seen by anyone (such as username or feedback) there is no problem. Am I missing something? Why can't I access any private data? I dont' get any error messages. Here is my source code:** public class EBayLibrary { private static final String configFileLocation = "config.properties"; private static String devID, appID, certID, serverUrl, userToken; ApiContext apiContext; public static void main(String[] args) { EBayLibrary ebl = new EBayLibrary(); ebl.init(); } public void init() { Properties config = new Properties(); try { config.load(new FileInputStream(configFileLocation)); //Get all the properties into local strings devID = config.getProperty("DevID"); appID = config.getProperty("AppID"); certID = config.getProperty("CertID"); serverUrl = config.getProperty("ServerUrl"); userToken = config.getProperty("UserToken"); // Instantiate ApiContext and initialize with token and Trading API URL apiContext = getApiContext(); //Create call object and execute the call GeteBayOfficialTimeCall apiCall = new GeteBayOfficialTimeCall(apiContext); Calendar cal = apiCall.geteBayOfficialTime(); //Handle the result returned System.out.println("Official eBay Time : " + cal.getTime().toString()); getSoldItems(); getUserData(); System.out.println("Fin"); } catch (Exception e) { System.out.println("Fail to get eBay official time."); e.printStackTrace(); } } // Initializes ApiContext with token and eBay API server URL private static ApiContext getApiContext() throws IOException { Properties config = new Properties(); try { config.load(new FileInputStream(configFileLocation)); } catch (Exception e) { System.out.println("ERROR: Could not open properties file\n:" + e.toString()); return null; } ApiContext apiContext = new ApiContext(); apiContext.getApiCredential().seteBayToken(userToken); apiContext.getApiCredential().getApiAccount().setApplication(appID); apiContext.getApiCredential().getApiAccount().setCertificate(certID); apiContext.getApiCredential().getApiAccount().setDeveloper(devID); ApiCredential cred = apiContext.getApiCredential(); cred.seteBayToken(userToken); apiContext.setApiServerUrl(serverUrl); return apiContext; } // -------------------------------------- // IN THIS FUNCTION I GET ONLY NULL LISTS // -------------------------------------- public void getSoldItems(){ GetMyeBaySellingCall soldItems = new GetMyeBaySellingCall(apiContext); GetMyeBayBuyingCall boughtItems = new GetMyeBayBuyingCall(apiContext); ItemListCustomizationType itemList = soldItems.getSoldList(); ItemListCustomizationType itemList2 = boughtItems.getWatchList(); if (itemList != null) { System.out.println("Item: " + itemList.getAny(0)); } else { System.out.println("Item list empty"); } if (itemList2 != null) { System.out.println("Item 2: " + itemList2.getAny(0)); } else { System.out.println("Item list 2 empty"); } } // -------------------------------------- // THIS FUNCTION WORKS JUST FINE // -------------------------------------- public void getUserData() { GetUserCall userCall = new GetUserCall(apiContext); userCall.setUserID("my_username"); System.out.println("Begin eBay API request, please wait... "); try { UserType userType = userCall.getUser(); System.out.println("A selection of data from the call:"); System.out.println( " User login: " + userType.getUserID() ); System.out.println( " In good standing: " + userType.isEBayGoodStanding().toString() ); System.out.println( " Email: " + userType.getEmail() ); System.out.println( " Positive feedback: " + userType.getPositiveFeedbackPercent().toString() + "%" ); System.out.println( " Registration date: " + userType.getRegistrationDate().getTime().toString() ); } catch (SdkException ex) { Logger.getLogger(EBayLibrary.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(EBayLibrary.class.getName()).log(Level.SEVERE, null, ex); } System.out.println("End eBay API request... "); }
ebay apiebay trading apigetmyebaysellingcallgetmyebaybuyingcallgetebayofficialtimecallgetusercall
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 chibierutonia, You should call the getReturnedSoldList() method to get the sold list returned in the GetMyeBaySelling response. Below are the code snippets for your reference : GetMyeBaySellingCall gmes = new GetMyeBaySellingCall(apiContext); DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[]{ DetailLevelCodeType.RETURN_ALL }; gmes.setDetailLevel(detailLevels); try { gmes.getMyeBaySelling(); PaginatedOrderTransactionArrayType returnedSoldListArry = gmes.getReturnedSoldList(); if (returnedSoldListArry != null) { OrderTransactionArrayType orderTransArrayType = returnedSoldListArry.getOrderTransactionArray(); OrderTransactionType[] ordeTransList = orderTransArrayType.getOrderTransaction(); for (OrderTransactionType orderTrans : ordeTransList) { OrderType order = null; TransactionType trans = null; // multi transactions Order if (orderTrans.getOrder() != null) { order = orderTrans.getOrder(); System.out.println("Multi transactions OrderID: " + order.getOrderID()); //... } // single item transaction else if (orderTrans.getTransaction() != null) { trans = orderTrans.getTransaction(); System.out.println("Single item transaction ItemID:" + trans.getItem().getItemID() + "-TransctionID:" + trans.getTransactionID()); //... } } } } catch (Exception e) { // handle exception here } Best Regards,
· 1
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.

It works now. Thank you very much!
0 Likes 0 ·

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.