eBay大中华区API开发者平台 开发者专区

搜 索
首页>API开发者平台>技术文档>Java SDK例程: RelistFixedPriceItem可以将已下架的一口价商品重新刊登上架

技术文档

问题
Java SDK例程: RelistFixedPriceItem可以将已下架的一口价商品重新刊登上架
解答
0
人觉得答案有帮助)

代码如下。相应的SOAP request附在文末。

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.InventoryTrackingMethodCodeType; 
import com.ebay.soap.eBLBaseComponents.ItemType; 
import com.ebay.soap.eBLBaseComponents.SiteCodeType; 
/** 
* Sample code to relist an item (without any modifications) using the RelistFixedPriceItem call 

* 1. Create an ApiContext Object 
* 2. Set the auth token and target api url (Webservice endpoint) 
* 3. Create a RelistFixedPriceItemCall object. 
* 4. Create an item object and set the SKU for the item whose field(s) is/are to added/modified. 
* 5. Set the InventoryTrackingMethod in the item object and set it to the ReviseFixedPriceItemCall object. 
* 6. Execute the API call ReviseFixedPriceItemCall#reviseFixedPriceItem() to revise the listing 
*/ 
public class RelistFPItemBasicSample { 
      
     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_REVISE_FPITEM_SKU1"); 
          item.setInventoryTrackingMethod(InventoryTrackingMethodCodeType.SKU); 

          try { 
               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(); 
     } 


 

 

  附件
   • XML document revisefp_basic_soap.xml

 


答案对您有帮助吗?

是,对我很有帮助
否,没解决我的问题