public static ApiContext createApiContext() {
ApiContext apiContext = new ApiContext();
ApiLogging apiLogging = new ApiLogging();
apiContext.setApiLogging(apiLogging);
CallRetry cr = new CallRetry();
cr.setMaximumRetries(3);
cr.setDelayTime(1000); // Wait for one second between each retry-call.
String[] apiErrorCodes = new String[]{"502"};
// Set trigger exceptions for CallRetry.
cr.setTriggerApiErrorCodes(apiErrorCodes);
// Build a dummy SdkSoapException so that we can get its Class.
Class[] tcs = new Class[]{com.ebay.sdk.SdkSoapException.class};
cr.setTriggerExceptions(tcs);
apiContext.setCallRetry(cr);
apiContext.setTimeout(120000);
// set the server url and credentials for Sandbox
apiContext.setApiServerUrl("https://api.sandbox.ebay.com/wsapi");
ApiCredential cred = apiContext.getApiCredential();
cred.seteBayToken("YOUR TOKEN");
apiContext.setApiCredential(cred);
// set the site
apiContext.setSite(SiteCodeType.US);
// Track inventory by SKU
item.setInventoryTrackingMethod(InventoryTrackingMethodCodeType.SKU);
// Specify unique SKU
item.setSKU("BASIC12345");
// Set Payment Method to PayPal
BuyerPaymentMethodCodeType[] arrPaymentMethods = new BuyerPaymentMethodCodeType[]{BuyerPaymentMethodCodeType.PAY_PAL};
item.setPayPalEmailAddress("test@pp.com");
item.setPaymentMethods(arrPaymentMethods);
// Specify Quantity, Start Price and the eBay category
item.setStartPrice(getAmount(11.0));
item.setCountry(CountryCodeType.US);
item.setCurrency(CurrencyCodeType.USD);
CategoryType category = new CategoryType();
category.setCategoryID("63889");
item.setPrimaryCategory(category);
item.setQuantity(10);