Skip to main content
Published: August 17 2010, 10:26:00 PMUpdated: November 28 2020, 8:35:32 PM

Use the EndFixedPriceItem call to end the specified fixed-price listing before the date and time at which it would normally end (per the listing duration). For e.g. you may need to use this call to pull down listing from the site if you discover that you are out of stock on that particular listing.

The following code sample shows how to end a listing using the EndFixedPriceItem call. The code was written using Java SDK v673.

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

/*  © 2010-2013 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.EndFixedPriceItemCall;
import com.ebay.soap.eBLBaseComponents.EndReasonCodeType;
import com.ebay.soap.eBLBaseComponents.SiteCodeType;

/**
* Sample code to end an item using EndFixedPriceItem call using eBay Java SDK v673
*
* 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 EndFixedPriceItemCall object.
* 4. Set the SKU, ending reason to the object.
* 5. Execute EndFixedPriceItemCall#endFixedPriceItem() to end the listing.
*
*/
public class EndFPItemSample {
     
     public static void endFixedPriceItem(){
          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
          
          EndFixedPriceItemCall endItem = new EndFixedPriceItemCall(apiContext);
          
          endItem.setSKU("CODE_SAMPLE_RELIST_VARIATION_SKU2");
          endItem.setEndingReason(EndReasonCodeType.NOT_AVAILABLE);
          
          try {
               endItem.endFixedPriceItem();
          } catch (ApiException e) {
               e.printStackTrace();
          } catch (SdkException e) {
               e.printStackTrace();
          } catch (Exception e) {
               e.printStackTrace();
          }
     }
     
     public static void main(String[] args) {
          endFixedPriceItem();
     }

}

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