Find the answer to your question
Advanced Search
Why do I get an error message that Country, StartPrice, Currency, and Quantity are not set in the AddItem SOAP request even though I have set them?
Not all the elements are required for all the calls and therefore, they are marked as optional. Since they are optional, .Net adds the Specified property on certain types, namely booleans and enumerations. In the case of ItemType they are required for AddItem but the ItemType is also reused for GetSellerEvents and some of these values are not returned. Hence you need to specify the values for the properties and also set the <property>Specified, to true. You need to set them to true to tell the serializer to send them over the wire.
Therefore, by having the Specified value you can tell .Net that it should or should not be sent. This is also helpful for responses as you can check the specified value, to see if it is true.
Here is a sample SOAP request using .NET:
public stringAddItem(string UUID)
{
eBaySoap.eBayAPIInterfaceService service = new SOAP.eBaySoap.eBayAPIInterfaceService();
string endpoint = "https://api.sandbox.ebay.com/wsapi";
string callName = "AddItem";
string siteId = "0";
string appId = "appid"; //use your app ID
string devId = "devid"; //use your dev ID
string certId = "certid"; //use your cert ID
string version = "555";
// Build the request URL
string requestURL = endpoint +"?callname=" + callName + "&siteid=" + siteId +"&appid=" + appId + "&version=" + version +"&routing=default";
// Assign the request URL to the servicelocator.
service.Url = requestURL;
// Set credentials
service.RequesterCredentials = new eBaySoap.CustomSecurityHeaderType();
service.RequesterCredentials.eBayAuthToken = "token"; //use your token
service.RequesterCredentials.Credentials = neweBaySoap.UserIdPasswordType();
service.RequesterCredentials.Credentials.AppId = appId;
service.RequesterCredentials.Credentials.DevId = devId;
service.RequesterCredentials.Credentials.AuthCert = certId;
// Make the call to AddItem
eBaySoap.AddItemRequestType request = new eBaySoap.AddItemRequestType();
request.Version = version;
eBaySoap.ItemType item = new eBaySoap.ItemType();
item.Title = "test";
item.Currency = eBaySoap.CurrencyCodeType.USD;
item.CurrencySpecified = true;
item.Country = eBaySoap.CountryCodeType.US;
item.PaymentMethods = new eBaySoap.BuyerPaymentMethodCodeType[1]{eBaySoap.BuyerPaymentMethodCodeType.PaymentSeeDescription};
// Set specified values
item.Description = "Desc";
item.Quantity = 1;
item.QuantitySpecified = true;
item.Location = "San Jose";
item.ListingDuration = eBaySoap.ListingDurationCodeType.Days_7;
item.ListingDurationSpecified = true;
item.PrimaryCategory = new eBaySoap.CategoryType();
item.PrimaryCategory.CategoryID = "1463";
item.StartPrice = new eBaySoap.AmountType();
item.StartPrice.currencyID = eBaySoap.CurrencyCodeType.USD;
item.StartPrice.Value = 20;
item.UUID = UUID;
request.Item = item;
eBaySoap.AddItemResponseType response = service.AddItem(request);
return response.ItemID;
}