Skip to main content
Published: August 25 2010, 3:06:00 AMUpdated: November 28 2020, 8:43:38 PM

The RelistFixedPriceItem call can be used to to relist fixed-price item that has ended. It is recommended to use this call instead of creating a new listing using the AddFixedPriceItem call to take advantage of the recent sales score associated with the listing.

Here is a Java RelistFixedPriceItem sample for re-listing a multi-variation item; a variation from the original listing is deleted and a new variation is added during the relist operation. This sample has been written using the Java SDK v673.

Below is the code. Corresponding SOAP request is attached with this article.

/*  © 2010-2012 eBay Inc., All Rights Reserved */
/* Licensed under CDDL 1.0 -  http://opensource.org/licenses/cddl1.php */

package com.ebay.sample;

import com.ebay.sdk.ApiContext;
import com.ebay.sdk.ApiCredential;
import com.ebay.sdk.ApiException;
import com.ebay.sdk.SdkException;
import com.ebay.sdk.call.RelistFixedPriceItemCall;
import com.ebay.soap.eBLBaseComponents.AmountType;
import com.ebay.soap.eBLBaseComponents.CurrencyCodeType;
import com.ebay.soap.eBLBaseComponents.InventoryTrackingMethodCodeType;
import com.ebay.soap.eBLBaseComponents.ItemType;
import com.ebay.soap.eBLBaseComponents.NameValueListArrayType;
import com.ebay.soap.eBLBaseComponents.NameValueListType;
import com.ebay.soap.eBLBaseComponents.SiteCodeType;
import com.ebay.soap.eBLBaseComponents.VariationType;
import com.ebay.soap.eBLBaseComponents.VariationsType;

/**
*
* Sample code for using RelistFixedPriceItem to relist an item with variations
*
* The following steps need to be done to delete a field from an existing listing.
*
* 1. Create an ApiContext Object.
* 2. Set the auth token and target api url (Webservice endpoint).
* 3. Create a RelistFixedPriceItem object.
* 4. Create an item object and set the SKU for the item.
* 5. Create a VariationType for each variation that is to be listed.
* 6. Add item specifics for each variation.
* 7. Set all the variations to VariationsType object and set this to the item using ItemType#setVariations(VariationsType)
* 8. Set the item as the itemToBeRelisted in the RelistFixedPriceItemCall object.
* 9. Add any field that is to be deleted to the RelistFixedPriceItemCall#setDeletedField(String[]) array.
* 10. Invoke RelistFixedPriceItemCall#relistFixedPriceItem() to re-list the item(A new item ID will be generated).
*
*
*/
public class RelistFPItemWithVariations {
     
     public static void relistFixedPriceItem(){
          ApiContext apiContext = new ApiContext();
          // set API Token to access eBay API Server
          ApiCredential cred = apiContext.getApiCredential();
          cred.seteBayToken("YourToken");
          
          apiContext.setApiServerUrl("https://api.sandbox.ebay.com/wsapi");// Pointing to sandbox for testing.
          apiContext.getApiLogging().setLogSOAPMessages(true);// This will log SOAP requests and responses
          apiContext.setSite(SiteCodeType.UK); // Set site to UK
          
          RelistFixedPriceItemCall relistCall = new RelistFixedPriceItemCall(
                    apiContext);

          ItemType item = new ItemType();

          item.setSKU("CODE_SAMPLE_RELIST_VARIATION_SKU2");
          item.setInventoryTrackingMethod(InventoryTrackingMethodCodeType.SKU);
          item.setTitle("**TEST ITEM-Relisting item with new title-DO NOT BID**");
          
          // Adding a new variation Blue - M
          VariationType variation1 = new VariationType();
          variation1.setSKU("CODE_SAMPLE_RELIST_VARIATION_SKU2_LBLUE");
          
          // Create variation specifics
          NameValueListType sizeVariation = new NameValueListType();
          sizeVariation.setName("Size");
          sizeVariation.setValue(new String[] { "M" });

          NameValueListType colourVariation = new NameValueListType();
          colourVariation.setName("Colour");
          colourVariation.setValue(new String[] { "Blue" });
          
          NameValueListArrayType nvListArray = new NameValueListArrayType();
          nvListArray.setNameValueList(new NameValueListType[] {sizeVariation,colourVariation});
          
          // add variation specifics to a variation object
          variation1.setVariationSpecifics(nvListArray);

          AmountType amt = new AmountType();
          amt.setCurrencyID(CurrencyCodeType.GBP);
          amt.setValue(12.00);
          
          variation1.setStartPrice(amt);
          variation1.setQuantity(10);
               
          // Adding a new variation Brown - L
          VariationType variation2 = new VariationType();
          variation2.setSKU("CODE_SAMPLE_RELIST_VARIATION_SKU2_LBROWN");
          
          // Create variation specifics
          NameValueListType sizeVariation2 = new NameValueListType();
          sizeVariation2.setName("Size");
          sizeVariation2.setValue(new String[] { "L" });

          NameValueListType colourVariation2 = new NameValueListType();
          colourVariation2.setName("Colour");
          colourVariation2.setValue(new String[] { "Brown" });
          
          NameValueListArrayType nvListArray2 = new NameValueListArrayType();
          nvListArray2.setNameValueList(new NameValueListType[] {sizeVariation2,colourVariation2});
          
          // add variation specifics to a variation object
          variation2.setVariationSpecifics(nvListArray2);

          AmountType amt2 = new AmountType();
          amt2.setCurrencyID(CurrencyCodeType.GBP);
          amt2.setValue(12.00);
          
          variation2.setStartPrice(amt);          
          variation2.setQuantity(10);          
          
          // Delete an existing variation Brown - M
          VariationType variation3 = new VariationType();
          variation3.setSKU("CODE_SAMPLE_RELIST_VARIATION_SKU2_MBROWN");
          variation3.setDelete(true);
          
          VariationsType variations  = new VariationsType();
          // add individual variations to a variations object
          variations.setVariation(new VariationType[]{variation1,variation2,variation3});
          
          item.setVariations(variations);
                    
          try {
               relistCall.setDeletedField(new String[] { "Item.SubTitle" });
               relistCall.setItemToBeRelisted(item);
               relistCall.relistFixedPriceItem();
               System.out.println("The sku : " + item.getSKU()
                         + " is relisted with new ItemID : "
                         + relistCall.getReturnedItemID());
          } catch (ApiException e) {
               e.printStackTrace();
          } catch (SdkException e) {
               e.printStackTrace();
          } catch (Exception e) {
               e.printStackTrace();
          }

     }

     public static void main(String[] args) {
          relistFixedPriceItem();
     }
}

 

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