Skip to main content
Published: June 27 2007, 4:33:00 PMUpdated: November 28 2020, 3:50:36 PM

Using eBay Java SDK to execute your first AddItem API Call




  This sample illustrates of using  eBay Java SDK framework to make AddItem call and list a Chinese auction on eBay Sandbox.  For using this sample you must have:
   1. got your sandbox keys that include three IDs (DevID, AppID, and CertID) and an API Token.
   2. obtained and installed the eBay Java SDK package.

  Attached to this article is a zipped project implementing the AddItem code.

 The source code in this Knowledge Base article is covered by this license agreement:
MIT License

 Detailed Description

Creating a standalone eBay Project named eBayApiRequest, which consists the file structure as below.   
       1. Java Source files
       2. Build, batch and properties files
       3. Plug your own devid, appid, cert, and token into the file.

Here is the souce code. 

Please refer the KB article titled Using Java SDK framework to execute your first API Call for error handling and API retrying.

package ebay.dts;

import com.ebay.soap.eBLBaseComponents.*;
import com.ebay.sdk.*;
import com.ebay.sdk.util.*;
import org.apache.axis.types.Token;

 * @author Zhuowei Yang
public class AppAddItem {
    private String configFile= "";
    private ApiContext apiContext;
    /** Creates a new instance of AddItem */
    public AppAddItem() {
        RequestHeaderParam requestHeaderParam = new  RequestHeaderParam();
        apiContext = requestHeaderParam.createContext(configFile);
        //Enable logging
        ApiLogging logging = new ApiLogging();   
     public static void  main(String[] args){
        AppAddItem aai = new AppAddItem();
        try {
            ItemType item = aai.buildItem();
            FeesType fees;
            AddItemCall call = new AddItemCall(aai.apiContext);
            fees = call.addItem();
        }catch(Exception e){
    private ItemType buildItem() throws Exception{
        String title = "Test. Do not bid";
        ItemType item = new ItemType();

        item.setDescription("This is a test item created by eBay SDK.");
        item.setStartPrice(new AmountType(10.00));
        item.setListingDuration(new org.apache.axis.types.Token("Days_7"));
        item.setLocation("San Jose, CA");
        CategoryType cat = new CategoryType();
        item.setQuantity(new Integer(1));
        // Payment method
        BuyerPaymentMethodCodeType[] arrPaymentMethods =
            new BuyerPaymentMethodCodeType[] {

        return item;
   private ShippingDetailsType getShippingDetails(){
// construct shipping details container
        ShippingDetailsType sd = new ShippingDetailsType();
        ShippingServiceOptionsType st1 = new ShippingServiceOptionsType();
        st1.setShippingService(new org.apache.axis.types.Token("UPSGround"));
        st1.setShippingServiceAdditionalCost(new AmountType(2.0));
        st1.setShippingServiceCost(new AmountType(10));
        st1.setShippingServicePriority(new Integer(1));
        st1.setShippingInsuranceCost(new AmountType(1.0));
        sd.setShippingServiceOptions(new ShippingServiceOptionsType[]{st1});
        return sd;


Version Info

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

API Schema Version511 
Java SDK Versionjavasdk v511.0 Full release

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