Skip to main content
Published: March 11 2010, 10:42:00 PMUpdated: November 28 2020, 8:17:06 PM

How to add local picture files to listing using Java SDK AddItemCall wrapper?

Detailed Description

  This sample illustrates the use of Java SDK AddItemCall wrapper to list an item that includes an image stored in local file system. The required steps are:

  1. Register EPS server URL in ApiContext object and  the String array object of the file name for the given images in AddItemCall object.

  2. Define the PictureDetail.GalleryTypeCodeType in ItemType object. 

/* *
* © 2010-2013 eBay Inc., All Rights Reserved
* Licensed under CDDL 1.0 -

import com.ebay.sdk.*;
import com.ebay.soap.eBLBaseComponents.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;

* @author zhuyang
public class AppAddItem {

    private ApiContext apiContext = new ApiContext();
    private static ApiLogging apiLogging = new ApiLogging();
    private static String[] pictureFiles = {"c:\\Sample.jpg"};
    String sandboxEPSURL = "";
    private static String TOKEN = "";
    private static String APISERVERURL = "";
    public static final String DATE_FORMAT_NOW = "yyyy-MM-dd-HHmmss";

    public AppAddItem() {
        System.out.println(" current time : " +;
        ApiCredential cred = new ApiCredential();
        //set api call credential
        //enable api logging
        //register EPS server URL in ApiContext object

    public static void main(String[] args) {
        AppAddItem agbb = new AppAddItem();
        ItemType item = agbb.buildItem(ListingTypeCodeType.FIXED_PRICE_ITEM);
        AddItemCall call = new AddItemCall(agbb.apiContext);
        //register the local picture files into AddItemCall object    
        try {
            System.out.println("Listed Item ID: " + item.getItemID());
        } catch (InterruptedException ie) {
        } catch (Exception e) {

    private ItemType buildItem(ListingTypeCodeType listingType) {
        ItemType item = null;
        item = new ItemType();
        item.setTitle("FIXED_PRICE_ITEM . Do not bid");
        item.setDescription("FIXED_PRICE_ITEM -  Do not bid");
        item.setLocation(" San Jose, CA");

        item.setQuantity(new Integer(1));
        // item.setScheduleTime(calAt);
        AmountType amount = new AmountType();
        amount = new AmountType();
        BuyerPaymentMethodCodeType[] paymentMethods = new BuyerPaymentMethodCodeType[]{

        CategoryType cat = new CategoryType();
        item.setDispatchTimeMax(new Integer(1));
        ReturnPolicyType rpt = new ReturnPolicyType();

        rpt.setDescription("Text description of return policy details");
        //define gallery picture type     
        PictureDetailsType pd = new PictureDetailsType();

        return item;

    private static ShippingDetailsType getShippingDetails() {
        // construct shipping details container
        ShippingDetailsType sd = new ShippingDetailsType();
        ShippingServiceOptionsType st1 = new ShippingServiceOptionsType();
        AmountType amount = new AmountType();
        st1.setShippingServicePriority(new Integer(1));
        sd.setShippingServiceOptions(new ShippingServiceOptionsType[]{st1});

        return sd;

    public static String now() {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
        return sdf.format(cal.getTime());



Version Info

The code example above was based on the versions specified below:

API Schema Version 639
Java SDK Version Java SDK v639 Full release

How well did this answer your question?
Answers others found helpful