public class AddFixedPriceItemWithProductIdentifier {
private static String USER_TOKEN=" YOUR TOKEN";
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(USER_TOKEN);
apiContext.setApiCredential(cred);
// Set site to US
apiContext.setSite(SiteCodeType.US);
// Set Payment Method to PayPal
BuyerPaymentMethodCodeType[] arrPaymentMethods = new BuyerPaymentMethodCodeType[]{BuyerPaymentMethodCodeType.PAY_PAL};
item.setPayPalEmailAddress("test@pp.com");
item.setPaymentMethods(arrPaymentMethods);
// Set shipping services
ShippingDetailsType sd = new ShippingDetailsType();
ShippingServiceOptionsType st1 = new ShippingServiceOptionsType();
st1.setShippingService("UPSGround");
AmountType shipAmt1 = new AmountType();
shipAmt1.setValue(4.0);
st1.setShippingServiceCost(shipAmt1);
AmountType shipAmt1Addnl = new AmountType();
shipAmt1Addnl.setValue(2.0);
// include catalog product information in the item description and catalog picture
product.setIncludePrefilledItemInformation(true);
product.setIncludeStockPhotoURL(true);
item.setProductListingDetails(product);
PictureDetailsType pics = new PictureDetailsType();
pics.setGalleryType(GalleryTypeCodeType.NONE);