Skip to main content
Published: July 23 2010, 4:35:00 PMUpdated: November 28 2020, 8:20:57 PM

Here is a basic sample written using the .NET SDK (v817) for listing a fixed price item to the UK site using the AddFixedPriceItem call. The sample has been written in C#.

The mandatory fields for listing an item are -

1. Title

2. Description

3. Country

4. PostalCode

5. Currency

6. StartPrice

7. CategoryID

8. ListingDuration

9. PaymentMethods

10. PayPalEmailAddress

11. ShippingDetails

12. DispatchTimeMax

13. ReturnPolicy

The item is set to be able to be tracked by its SKU number. Therefore a unique SKU number needs to be specified in the request. As a best practice it is recommended to list an item by specifying its Condition. 

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

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

using eBay.Service.Call;
using eBay.Service.Core.Sdk;
using eBay.Service.Util;
using eBay.Service.Core.Soap;

namespace Trading_Samples
{
    public class AddFixedPriceItem
    {
       //AddFPItem - Basic listing
        private void AddFPItemCall()
        { 
                       
           //create the context
            ApiContext context = new ApiContext();

            //set the User token
            context.ApiCredential.eBayToken = "You token here";
           
            //set the server url. Pointing to Sandbox
            context.SoapApiServerUrl = "https://api.sandbox.ebay.com/wsapi";

            //enable logging
            context.ApiLogManager = new ApiLogManager();
            context.ApiLogManager.ApiLoggerList.Add(new FileLogger("log.txt", true, true, true));
            context.ApiLogManager.EnableLogging = true;

            //set the version
            context.Version = "817";
            context.Site = SiteCodeType.UK;

            //create the call object
            AddFixedPriceItemCall AddFPItemCall = new AddFixedPriceItemCall(context);

            //Send UUID with the request
            AddFPItemCall.AutoSetItemUUID = true;

            ItemType item = new ItemType();

            //set the item condition depending on the value from GetCategoryFeatures
            item.ConditionID = 1000;  //new with tags

            //Basic properties of a listing
            item.Country = CountryCodeType.GB;
            item.Currency = CurrencyCodeType.GBP;

            // Track inventory by SKU
            item.InventoryTrackingMethod = InventoryTrackingMethodCodeType.SKU;

            // Specify unique SKU
            item.SKU = "BASIC1234";

            item.Description = "test - do not bid or buy";
            item.Title = "test - do not bid or buy";
            item.SubTitle = "Test Item";
            item.ListingDuration = "Days_7";

            //Set Payment Method to PayPal
            item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
            item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PayPal);
            item.PayPalEmailAddress = "your sandbox paypal email account here";

            item.PostalCode = "SE6 1AL";

            //Specify Shipping Services
            item.DispatchTimeMax = 3;
            item.ShippingDetails = new ShippingDetailsType();
            item.ShippingDetails.ShippingServiceOptions = new ShippingServiceOptionsTypeCollection();

            ShippingServiceOptionsType shipservice1 = new ShippingServiceOptionsType();
            shipservice1.ShippingService = "UK_SellersStandardRate";
            shipservice1.ShippingServicePriority = 1;
            shipservice1.ShippingServiceCost = new AmountType();
            shipservice1.ShippingServiceCost.currencyID = CurrencyCodeType.GBP;
            shipservice1.ShippingServiceCost.Value = 1.0;

            shipservice1.ShippingServiceAdditionalCost = new AmountType();
            shipservice1.ShippingServiceAdditionalCost.currencyID = CurrencyCodeType.GBP;
            shipservice1.ShippingServiceAdditionalCost.Value = 1.0;

            item.ShippingDetails.ShippingServiceOptions.Add(shipservice1);

            ShippingServiceOptionsType shipservice2 = new ShippingServiceOptionsType();
            shipservice2.ShippingService = "UK_RoyalMailFirstClassStandard";
            shipservice2.ShippingServicePriority = 2;
            shipservice2.ShippingServiceCost = new AmountType();
            shipservice2.ShippingServiceCost.currencyID = CurrencyCodeType.GBP;
            shipservice2.ShippingServiceCost.Value = 4.0;

            shipservice2.ShippingServiceAdditionalCost = new AmountType();
            shipservice2.ShippingServiceAdditionalCost.currencyID = CurrencyCodeType.GBP;
            shipservice2.ShippingServiceAdditionalCost.Value = 1.0;

            item.ShippingDetails.ShippingServiceOptions.Add(shipservice2);

            //Specify Return Policy
            item.ReturnPolicy = new ReturnPolicyType();
            item.ReturnPolicy.ReturnsAcceptedOption = "ReturnsAccepted";

            //Specify Quantity, Start Price and the eBay category
            item.Quantity = 1;
            item.StartPrice = new AmountType();
            item.StartPrice.currencyID = CurrencyCodeType.GBP;
            item.StartPrice.Value = 1;
            item.PrimaryCategory = new CategoryType();
            item.PrimaryCategory.CategoryID = "88433";

            //Add pictures
            item.PictureDetails = new PictureDetailsType();
            item.PictureDetails.PictureURL = new StringCollection();
            item.PictureDetails.PictureURL.Add("http://i.ebayimg.sandbox.ebay.com/00/s/MzcwWDUwMA==/  $(KGrHqVHJCkFDJT8SvTpBReF12)8(Q~~60_1.JPG?set_id=8800005007");

            AddFPItemCall.Item = item;

            //set the item and make the call
            AddFPItemCall.Execute();

            Console.WriteLine(AddFPItemCall.ApiResponse.Ack + " " + ": Listed simple item " + AddFPItemCall.ApiResponse.ItemID); 
        } 

   }

}

 

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