Welcome Guest. Sign in or Signup

1 Answers

Java SDK: AddFixedPriceItem sample for listing an item with a product identifier in US

Asked by: 243 views Programming

 

Here is a Java  SDK AddFixedPriceItem sample for listing an item with a product identifier (UPC).

import com.ebay.sdk.*;
import com.ebay.sdk.call.*;
import com.ebay.soap.eBLBaseComponents.*;

public class AddFixedPriceItemWithProductIdentifier {

    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);

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

        // Set site to US
        apiContext.setSite(SiteCodeType.US); 

        return apiContext;
    }

    private static FeesType addWithUPC() throws ApiException, SdkException,  Exception {

        FeesType fee = null;
        AddFixedPriceItemCall request = new AddFixedPriceItemCall(createApiContext());

        ItemType item = new ItemType();

        item.setTitle(“*** TEST ITEM DO NOT BID ***”);
        item.setDescription(“Item created for testing. Please DO NOT BID”);

        // set the item condition depending on the value from GetCategoryFeatures
        item.setConditionID(1000);

        item.setPostalCode(“95125”);
        item.setListingDuration(“GTC”);

        // Track inventory by SKU
        item.setInventoryTrackingMethod(InventoryTrackingMethodCodeType.SKU);

    &#160