Skip to main content
Published: July 10 2006, 11:34:00 AMUpdated: November 28 2020, 1:14:16 PM

Why am I getting an error for ListingDurationTypeCode and ShippingServiceCodeType ever since I upgraded to .NET SDK 459?

Why am I getting an error for ListingDurationTypeCode and ShippingServiceCodeType ever since I upgraded to .NET SDK 459?

All schema elements that were previously based on ShippingServiceCodeType and ListingDurationCodeType are now based on xs:token (essentially string).  So you need to change your code from using an enumeration to a string for ListingDuration and ShippingService.  You now need to use GeteBayDetails for retrieving the list of available shipping services and GetCategoryFeatures for listing durations.  Please see the Release Notes for more information.

Here is a sample .NET code using the SDK to make an AddItem call :

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

namespace SDK3Examples
{

public class AddItem
{
public string AddItem(string UUID)
{
   AddItemCall addItem = new AddItemCall(GetContext());
    ItemType item = new ItemType();   
   
item.Currency = CurrencyCodeType.USD;
    item.Country = CountryCodeType.US;
    item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
    item.PaymentMethods.AddRange(new BuyerPaymentMethodCodeType[] {BuyerPaymentMethodCodeType.PayPal});
    item.PayPalEmailAddress = "test@test.com";
    item.Title = "title";
    item.Quantity = 1;
    item.PostalCode = "95125";
    // ListingDuration is now a string, so change item.ListingDuration = ListingDurationCodeType.Days_7  to  item.ListingDuration = "Days_7"
   
item.ListingDuration = "Days_7";
    item.PrimaryCategory = new CategoryType();
    item.PrimaryCategory.CategoryID = "1463";
    item.StartPrice = new AmountType();
    item.StartPrice.currencyID = CurrencyCodeType.USD;
    item.StartPrice.Value = 20;
    item.UUID = UUID;
         
    item.ShippingDetails = new ShippingDetailsType();
    item.ShippingDetails.ShippingServiceOptions = new ShippingServiceOptionsTypeCollection();
    ShippingServiceOptionsType[] opt = new ShippingServiceOptionsType[1];
    opt[0] = new ShippingServiceOptionsType();    
    opt[0].ShippingServiceCost = new AmountType();
    opt[0].ShippingServiceCost.currencyID = CurrencyCodeType.USD;
    opt[0].ShippingServiceCost.Value = 5;
    // ShippingService is now a string
    //so change  opt[0].ShippingService = ShippingServiceCodeType.USPSPriority  to  opt[0].ShippingService = "USPSPriority";
    opt[0].ShippingService = "USPSPriority";
    opt[0].ShippingServicePriority = 1;
    item.ShippingDetails.ShippingServiceOptions.Add(opt[0]);

    item.ShipToLocations = new StringCollection();
    item.ShipToLocations.Add("US");

    FeeTypeCollection fees = addItem.AddItem(item);
    return  item.ItemID;
}

    public ApiContext GetContext()
    {
       ApiContext context = new ApiContext();

  // Credentials for the call
  context.ApiCredential.ApiAccount.Developer = "devID";
  context.ApiCredential.ApiAccount.Application = "appID";
  context.ApiCredential.ApiAccount.Certificate = "certID";
  context.ApiCredential.eBayToken = "token";

  // Set the URL
  context.SoapApiServerUrl = "https://api.sandbox.ebay.com/wsapi"; 

  // Set logging
  context.ApiLogManager = newApiLogManager();
  context.ApiLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("Messages.log", true, true, true));
  context.ApiLogManager.EnableLogging = true;

  // Set the version
  context.Version = "459";

  return context;

    }

}

}

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