XML eBay Trading API - addItem with multiple shipp

2019-08-19 05:43发布

I want to list some item on eBay via there Trading API, but their API is very complicated and I need some help.

I can list items on eBay via the API very well but I can't seem to figure out how to have more than one shipping option as I can do on the eBay addItem page

Here is the shipping setting I need to have on eBay via the API http://i.cubeupload.com/F4oURU.png

and this is my xml

<?xml version="1.0" encoding="utf-8"?>  
<AddItemsRequest xmlns="urn:ebay:apis:eBLBaseComponents">  
<ErrorLanguage>en_US</ErrorLanguage>  
<AddItemRequestContainer>  
<MessageID>100</MessageID>  
<Item>  
<StartPrice currencyID=\"CAD\">223.96</StartPrice>  
<CategoryMappingAllowed>true</CategoryMappingAllowed>  
<ConditionID>1000</ConditionID>  
<Country>CA</Country>  
<Currency>CAD</Currency>  
<Title>TEST</Title>  
<Description>DEscription</Description>  
<DispatchTimeMax>3</DispatchTimeMax>  
<ListingDuration>Days_7</ListingDuration>  
<ListingType>FixedPriceItem</ListingType>  
<PaymentMethods>PayPal</PaymentMethods>  
<PayPalEmailAddress>  [--  myPayPalEmail --]  </PayPalEmailAddress>  
<PictureDetails>  
<Item.PictureDetails.PictureURL>  
http://www.jccayer.com/productphoto/2793-22-1_ep1.jpg  
</Item.PictureDetails.PictureURL>  
<PictureURL>http://www.jccayer.com/productphoto/2793-22-1_ep1.jpg</PictureURL>  
</PictureDetails>  
<PostalCode>K0A1M0</PostalCode>  
<PrimaryCategory>  
<CategoryID>279</CategoryID>  
</PrimaryCategory>  
<Quantity>6</Quantity>  
<ReturnPolicy>  
<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>  
<RefundOption>MoneyBack</RefundOption>  
<ReturnsWithinOption>Days_30</ReturnsWithinOption>  
<Description>Text description of return policy details</Description>  
<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>  
</ReturnPolicy>  
<ShippingDetails>  
<ShippingType>Flat</ShippingType>  
<ShippingServiceOptions>  
<ShippingService>CA_UPSStandardCanada</ShippingService>  
<ShippingServiceCost>21.50</ShippingServiceCost>  
<ShippingServiceAdditionalCost>5.00</ShippingServiceAdditionalCost>  
<ShippingServicePriority>1</ShippingServicePriority>  
</ShippingServiceOptions>  
<InternationalShippingServiceOption>  
<ShippingService>CA_UPSStandardUnitedStates</ShippingService>  
<ShippingServiceCost>50.50</ShippingServiceCost>  
<ShippingServiceCost>10.00</ShippingServiceCost>  
<ShipToLocation></ShipToLocation>  
<ShippingServicePriority>2</ShippingServicePriority>  
</InternationalShippingServiceOption>  
</ShippingDetails>  
<Site>Canada</Site>  
</Item>  
</AddItemRequestContainer>  
<RequesterCredentials>  
<eBayAuthToken>[INSERT YOUR OWN AUTH TOKEN]</eBayAuthToken>  
</RequesterCredentials>  
</AddItemsRequest>

Does anyone have an idea how I can match those setting on that picture?

标签: xml ebay-api
1条回答
可以哭但决不认输i
2楼-- · 2019-08-19 06:17

This walks you through the XML needed to specify shipping details for an item on eBay.

Example Shipping Details

The shipping cost model used by the seller is the Flat model. The seller offers domestic shipping within Canada via UPS Standard Canada at a charge of CAD($)15.99 for the first item and $6.00 for each additional. The item can also be shipped internationally and two services are offered for this. The first international service only ships to the United States using UPS Standard United States and costs $21.08 for the first item and $8.00 for each additional. The second service costs $69.32 for the first item and $29.00 for each additional. UPS Worldwide Expedited is used and will ship to the following locations.

  • N. and S. America
  • Mexico
  • Germany
  • Europe
  • France
  • United Kingdom
  • Japan
  • Asia
  • Taiwan
  • Australia

The XML

Shipping information is specified in the ShippingDetails element of your request. This is of the type ShippingDetailsType and a complete list of fields is available here.

<ShippingDetails>
    <!-- Domestic and international shipping details will be added here -->
</ShippingDetails>

The first piece of information we can add to ShippingDetails is the shipping model that the seller is using which in this case is Flat.

<ShippingType>Flat</ShippingType>

There are many different values that could be entered as the ShippingType and a complete list can be found here.

We can now move onto the domestic shipping part of the request. You can specify up to a maximum of 4 domestic shipping services. Each service is a ShippingServiceOptions element and is of the type ShippingServiceOptionsType. A complete list of fields is available here.

<ShippingServiceOptions>
    <!-- Shipping costs and options related to a 
         domestic shipping service will be added here -->
</ShippingServiceOptions>

To control the order in which the domestic shipping services will appear in the View Item and Checkout page the seller can specify a priority. A service with a priority of 1 will appear at the top and a service with value of 4 will appear at the bottom. Note that in this example there is only one domestic shipping service so the priority is optional but it does no harm to include it.

<ShippingServicePriority>1</ShippingServicePriority>

Specifying the cost of the shipping service is done with the ShippingServiceCost element. Since this seller is also charging for additional items the ShippingServiceAdditionalCost element needs to be specified as well.

<ShippingServiceCost>15.99</ShippingServiceCost>
<ShippingServiceAdditionalCost>6.00</ShippingServiceAdditionalCost>

Indicating that UPS Standard Canada will be used is done through the ShippingService element.

<ShippingService>CA_UPSStandardCanada</ShippingService>

Note that you do not actually specify UPS Standard Canada but instead use the value *CA_UPSStandardCanada*. Obtaining the correct value to use is outside the scope of this example but can be summarised as follows.

  • Make a call to GeteBayDetails with DetailName set to ShippingServiceDetails.
  • In the response iterate through each ShippingServiceDetails element and check for the existence of ValidForSellingFlow.
  • If ValidForSellingFlow exists read in the value of ShippingService.
  • More information can be found here.

We can now begin the first of the international shipping services. You can specify up to a maximum of 5 international shipping services. Each service is a InternationalShippingServiceOption element that is of the type InternationalShippingServiceOptionsType. A complete list of fields is available here.

<InternationalShippingServiceOption>
    <!-- Shipping costs and options related to an 
         international shipping service will be added here -->
</InternationalShippingServiceOption>

Again the seller can specify a priority for each shipping service and for this we will enter a value of 1. Note that priorities are only compared between shipping services of the same type. This means that even though we have set a priority of 1 for both a domestic and international shipping service they will not be compared to each other when determining the order that they will appear.

<ShippingServicePriority>1</ShippingServicePriority>

We can now add the costs for using this service.

<ShippingServiceCost>21.08</ShippingServiceCost>
<ShippingServiceAdditionalCost>8.00</ShippingServiceAdditionalCost>

UPS Standard United States is also added. Notice again that we don't actually specify UPS Standard United States but instead use a value that was retrieved when calling GeteBayDetails.

<ShippingService>CA_UPSStandardUnitedStates</ShippingService>

The seller has specified that this international shipping service will only ship to the United States. Indicating which location or region that the seller will ship to is done via the ShipToLocation element.

<ShipToLocation>US</ShipToLocation>

Once again we don't actually specify United States but instead use the value US. Obtaining the correct value to use is also outside the scope of this example but can be summarised as follows.

  • Make a call to GeteBayDetails with DetailName set to ShippingLocationDetails.
  • In the response iterate through each ShippingLocationDetails element and read in the value of ShippingLocation.
  • More information can be found here.

Building the second international shipping service follows the same steps as the first. Notice that we set a priority of 2 as the seller wants it to appear below the first international shipping service. In addition several ShipToLocation elements have been specified to indicate the many regions that the seller will ship to with this service.

<InternationalShippingServiceOption>
    <ShippingServicePriority>2</ShippingServicePriority>
    <ShippingServiceCost>69.32</ShippingServiceCost>
    <ShippingServiceAdditionalCost>29.00</ShippingServiceAdditionalCost>
    <ShippingService>CA_UPSWorldWideExpedited</ShippingService>
    <ShipToLocation>Americas</ShipToLocation>
    <ShipToLocation>TW</ShipToLocation>
    <ShipToLocation>Asia</ShipToLocation>
    <ShipToLocation>AU</ShipToLocation>
    <ShipToLocation>MX</ShipToLocation>
    <ShipToLocation>DE</ShipToLocation>
    <ShipToLocation>FR</ShipToLocation>
    <ShipToLocation>Europe</ShipToLocation>
    <ShipToLocation>GB</ShipToLocation>
    <ShipToLocation>JP</ShipToLocation>
</InternationalShippingServiceOption> 

Putting together all the pieces results in the following XML.

<ShippingDetails>
    <ShippingType>Flat</ShippingType>
    <ShippingServiceOptions>
        <ShippingServicePriority>1</ShippingServicePriority>
        <ShippingServiceCost>15.99</ShippingServiceCost>
        <ShippingServiceAdditionalCost>6.00</ShippingServiceAdditionalCost>
        <ShippingService>CA_UPSStandardCanada</ShippingService>
    </ShippingServiceOptions>
    <InternationalShippingServiceOption>
        <ShippingServicePriority>1</ShippingServicePriority>
        <ShippingServiceCost>21.08</ShippingServiceCost>
        <ShippingServiceAdditionalCost>8.00</ShippingServiceAdditionalCost>
        <ShippingService>CA_UPSStandardUnitedStates</ShippingService>
        <ShipToLocation>US</ShipToLocation>
    </InternationalShippingServiceOption>        
    <InternationalShippingServiceOption>
        <ShippingServicePriority>2</ShippingServicePriority>
        <ShippingServiceCost>69.32</ShippingServiceCost>
        <ShippingServiceAdditionalCost>29.00</ShippingServiceAdditionalCost>
        <ShippingService>CA_UPSWorldWideExpedited</ShippingService>
        <ShipToLocation>Americas</ShipToLocation>
        <ShipToLocation>TW</ShipToLocation>
        <ShipToLocation>Asia</ShipToLocation>
        <ShipToLocation>AU</ShipToLocation>
        <ShipToLocation>MX</ShipToLocation>
        <ShipToLocation>DE</ShipToLocation>
        <ShipToLocation>FR</ShipToLocation>
        <ShipToLocation>Europe</ShipToLocation>
        <ShipToLocation>GB</ShipToLocation>
        <ShipToLocation>JP</ShipToLocation>
    </InternationalShippingServiceOption>
</ShippingDetails>

An example listing using these shipping details can be found here. Note that this item may no longer exist.

查看更多
登录 后发表回答