Skip to main content
Published: May 11 2011, 2:47:00 PMUpdated: November 28 2020, 9:46:23 PM

C# .NET US Motors Parts & Accessories listing sample

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

using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

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

namespace Merchant_OnBoarding_Trading_Samples
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            //create the context
            ApiContext context = new ApiContext();
           context.Site = SiteCodeType.eBayMotors;

            //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 = "817";            
          
           //create the call object
            AddFixedPriceItemCall AddFixedPriceItemCall = new AddFixedPriceItemCall(context);
             AddFixedPriceItemCall.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; //1000 - new , 3000 - used
            item.Site = SiteCodeType.eBayMotors;

            //Basic properties of a listing
            item.Country = CountryCodeType.US;
            item.Currency = CurrencyCodeType.USD;

            item.Description = "Your Desccription here";
            item.Title = "Your title here";
            //item.SubTitle = "Test Item";
            item.ListingDuration = "Days_30";

            item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
            item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PayPal);
            item.PayPalEmailAddress = "lmsbuy_1230058240_biz@yahoo.com";
            item.PostalCode = "60612";

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

            //Standard Shipping
            ShippingServiceOptionsType shipservice1 = new ShippingServiceOptionsType();
            shipservice1.ShippingService = "ShippingMethodStandard";
            shipservice1.ShippingServicePriority = 1;
            shipservice1.ShippingServiceCost = new AmountType();
            shipservice1.ShippingServiceCost.currencyID = CurrencyCodeType.USD;
            shipservice1.ShippingServiceCost.Value = 0.0;

            item.ShippingDetails.ShippingServiceOptions.Add(shipservice1);

            //Local Pickup
            ShippingServiceOptionsType shipservice2 = new ShippingServiceOptionsType();
            shipservice2.ShippingService = "Pickup";
            shipservice2.ShippingServicePriority = 2;
            shipservice2.ShippingServiceCost = new AmountType();
            shipservice2.ShippingServiceCost.currencyID = CurrencyCodeType.USD;
            shipservice2.ShippingServiceCost.Value = 0.0;

            item.ShippingDetails.ShippingServiceOptions.Add(shipservice2);

            //Specify Return Policy
            item.ReturnPolicy = new ReturnPolicyType();
            item.ReturnPolicy.ReturnsAcceptedOption = "ReturnsAccepted";
            item.ReturnPolicy.RefundOption = "MoneyBack";
            item.ReturnPolicy.ReturnsWithinOption = "Days_14";
            item.ReturnPolicy.Description = "Your return policy description here";
            

            item.Quantity = 1;
            item.StartPrice = new AmountType();
            item.StartPrice.currencyID = CurrencyCodeType.USD;
            item.StartPrice.Value = 20;
            item.PrimaryCategory = new CategoryType();
            item.PrimaryCategory.CategoryID = "66471";

            //Add Item Specifics - Recommended.
            //Here is a sample to demonstrate how. Call GetCategorySpecifics to get a list of the available item specifics
            item.ItemSpecifics = new NameValueListTypeCollection();

            NameValueListTypeCollection ItemSpecs = new NameValueListTypeCollection();

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

            nv1.Name = "Tire Type";
            valueCol1.Add("All Season");
            nv1.Value = valueCol1;

            ItemSpecs.Add(nv1);

            NameValueListType nv2 = new NameValueListType();
            StringCollection valueCol2 = new StringCollection();
            nv2.Name = "Tire Brand";
            valueCol2.Add("Michelin");
            nv2.Value = valueCol2;
            ItemSpecs.Add(nv2);

            NameValueListType nv3 = new NameValueListType();
            StringCollection valueCol3 = new StringCollection();
            nv3.Name = "Car Type";
            valueCol3.Add("Passenger/Performance");
            nv3.Value = valueCol3;
            ItemSpecs.Add(nv3);

            NameValueListType nv4 = new NameValueListType();
            StringCollection valueCol4 = new StringCollection();
            nv4.Name = "Rim Diameter";
            valueCol4.Add("17");
            nv4.Value = valueCol4;
            ItemSpecs.Add(nv4);
            
            NameValueListType nv5 = new NameValueListType();
            StringCollection valueCol5 = new StringCollection();
            nv5.Name = "Section Width";
            valueCol5.Add("215");
            nv5.Value = valueCol5;
            ItemSpecs.Add(nv5);

            NameValueListType nv6 = new NameValueListType();
            StringCollection valueCol6 = new StringCollection();
            nv6.Name = "Aspect Ratio";
            valueCol6.Add("55");
            nv6.Value = valueCol6;
            ItemSpecs.Add(nv6);

            NameValueListType nv7 = new NameValueListType();
            StringCollection valueCol7 = new StringCollection();
            nv7.Name = "DOT";
            valueCol7.Add("1208");
            nv7.Value = valueCol7;
            ItemSpecs.Add(nv7);

            NameValueListType nv8 = new NameValueListType();
            StringCollection valueCol8 = new StringCollection();
            nv8.Name = "Load Index";
            valueCol8.Add("93");
            nv8.Value = valueCol8;
            ItemSpecs.Add(nv8);

            NameValueListType nv9 = new NameValueListType();
            StringCollection valueCol9 = new StringCollection();
            nv9.Name = "Speed Index";
            valueCol9.Add("V");
            nv9.Value = valueCol9;
            ItemSpecs.Add(nv9);

            NameValueListType nv10 = new NameValueListType();
            StringCollection valueCol10 = new StringCollection();
            nv10.Name = "Tread Depth";
            valueCol10.Add("3/32 - 4/32");
            nv10.Value = valueCol10;
            ItemSpecs.Add(nv10);

            item.ItemSpecifics = ItemSpecs;
            
            //Add pictures - Recommended
            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");

            AddFixedPriceItemCall.Item = item;

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

            Console.WriteLine(AddFixedPriceItemCall.ApiResponse.Ack + " " + ": Listed motors item " + AddFixedPriceItemCall.ApiResponse.ItemID);
        }

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