Skip to main content
Published: July 14 2010, 4:10:00 PMUpdated: November 28 2020, 1:48:05 PM

.NET SDK sample to set the condition for an item

To set the item condition using the new item condition model you need to:

1. Make a call to GetCategoryFeatures to get the applicable condition IDs and DisplayNames
2. Use the ID for the appropriate DisplayName in the AddItem request

Here is the sample code using .NET SDK:

Create the context object:

using System;
usingeBay.Service.Call;
usingeBay.Service.Core.Sdk;
usingeBay.Service.Util;
usingeBay.Service.Core.Soap;


//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 = "673";

Make the GetCategoryFeatures call:

//create the call object for GetCategoryFeatures
GetCategoryFeaturesCall call = new GetCategoryFeaturesCall(context);

//set the CategoryID
call.CategoryID = "20714";

//view all the nodes and get all the details
call.ViewAllNodes = true;
call.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);

//execute the request
call.Execute();

//if the response contains more than 0 categories iterate through each
if (call.CategoryList.Count > 0)
{
    for (int i = 0; i < call.CategoryList.Count; i++)
    {
        CategoryFeatureType catFeature = call.CategoryList[0];

        //get the categoryID
        string catID = catFeature.CategoryID;

        //if condition is available
        if (catFeature.ConditionEnabledSpecified == true && catFeature.ConditionEnabled == ConditionEnabledCodeType.Enabled)
        {
            //iterate through each condition node
            foreach (ConditionType condition in catFeature.ConditionValues.Condition) 
           {
                //get the condition name and value
                string conditionName = condition.DisplayName;
                int conditionValue = condition.ID;
            }

        }

    }

}

Make the AddItem call with the conditionID:

//create the call object
AddItemCall additemCall = new AddItemCall(context);

//create an item object and set the properties
ItemType
item = new ItemType();
item.Country = CountryCodeType.US;
item.Currency = CurrencyCodeType.USD;
item.Description = "test - do not bid";
item.Title = "test - do not bid";
item.Quantity = 1;
item.ListingDuration = "Days_7";
item.PrimaryCategory = new CategoryType();
item.PrimaryCategory.CategoryID = "20714";
call.AutoSetItemUUID = true;
item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PayPal);
item.PayPalEmailAddress = "test@test.com";
item.StartPrice = new AmountType();
item.StartPrice.currencyID = CurrencyCodeType.USD;
item.StartPrice.Value = 10;
item.PostalCode = "95125";
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");
item.DispatchTimeMax = 3;
item.ShippingDetails = new ShippingDetailsType();
item.ShippingDetails.ShippingServiceOptions = new ShippingServiceOptionsTypeCollection();
ShippingServiceOptionsType
shipservice = new ShippingServiceOptionsType();
shipservice.ShippingService = "UPSGround";
shipservice.ShippingServicePriority = 1;
shipservice.ShippingServiceCost = new AmountType();
shipservice. ShippingServiceCost.currencyID = CurrencyCodeType.USD;
shipservice.ShippingServiceCost.Value = 1.0;
item.ShippingDetails.ShippingServiceOptions.Add(shipservice);
item.ReturnPolicy = new ReturnPolicyType();
item.ReturnPolicy.ReturnsAcceptedOption = "ReturnsAccepted";

//set the item condition depending on the value from GetCategoryFeatures
item.ConditionID = 1000;
additemCall.Item = item
;

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

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