Skip to main content
Published: May 02 2011, 6:09:00 AMUpdated: November 28 2020, 9:24:46 PM

Here is a sample written in C# using the .NET SDK (v715) for listing a fixed price item to the AU site item using the AddFixedPriceItem call.

This sample shows how to specify item specifics as name-value pairs for the listing. Whenever possible, it is recommended that the item be listed with item specifics.

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

/* 2012-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 - Listing with ItemSpecifics
        private static void AddFPItemWithItemSpecifics()
        {

            //create the context
            ApiContext context = new ApiContext();

            //set the User token
            context.ApiCredential.eBayToken = "Your Token";

            //set the server url
            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 = "687";
            context.Site = SiteCodeType.Australia;

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

            AddFPItemCall.AutoSetItemUUID = true;

            //create an item object and set the properties
            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.AU;
            item.Currency = CurrencyCodeType.AUD;

            //Track item by SKU
            item.InventoryTrackingMethod = InventoryTrackingMethodCodeType.SKU;
            item.SKU = "ITMSPECS1234";

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

            item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
            item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PayPal);
            item.PayPalEmailAddress = "test@test.com";
            item.Location = "Australia";

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

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

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

            item.ShippingDetails.ShippingServiceOptions.Add(shipservice1);

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

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

            item.ShippingDetails.ShippingServiceOptions.Add(shipservice2);

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

            item.Quantity = 10;
            item.StartPrice = new AmountType();
            item.StartPrice.currencyID = CurrencyCodeType.AUD;
            item.StartPrice.Value = 10;
            item.PrimaryCategory = new CategoryType();
            item.PrimaryCategory.CategoryID = "57991";

            //Add Item Specifics
            item.ItemSpecifics = new NameValueListTypeCollection();

            NameValueListTypeCollection ItemSpecs = new NameValueListTypeCollection();

            NameValueListType nv1 = new NameValueListType();
            StringCollection valueCol1 = new StringCollection();


            nv1.Name = "Brand";
            valueCol1.Add("Ralph Lauren");
            nv1.Value = valueCol1;

            ItemSpecs.Add(nv1);

            NameValueListType nv2 = new NameValueListType();
            StringCollection valueCol2 = new StringCollection();
            nv2.Name = "Size";
            valueCol2.Add("L");
            nv2.Value = valueCol2;
            ItemSpecs.Add(nv2);

            NameValueListType nv3 = new NameValueListType();
            StringCollection valueCol3 = new StringCollection();
            nv3.Name = "Colour";
            valueCol3.Add("Black");
            nv3.Value = valueCol3;
            ItemSpecs.Add(nv3);

            item.ItemSpecifics = ItemSpecs;

            //Add pictures
            item.PictureDetails = new PictureDetailsType();
            item.PictureDetails.PictureURL = new StringCollection();
            item.PictureDetails.PictureURL.Add("http://i2.sandbox.ebayimg.com/03/i/00/3f/c5/92_1.JPG?set_id=8800004005");

            AddFPItemCall.Item = item;

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

            Console.WriteLine(AddFPItemCall.ApiResponse.Ack + " " + AddFPItemCall.ApiResponse.ItemID);
        } 
   }
}

 

How well did this answer your question?