Java SDK - How can I find the condition IDs for a specified category and upload an item with one of the IDs? Home Knowledge Base Java SDK - How can I find the condition IDs for a specified category and upload an item with one of the IDs? Find the answer to your question
Advanced Search Product -Select Product- Trading API Shopping API Merchandising API Feedback API Finding API Product Services Sandbox Others MIP Media API Notification API Identity API Charity API Taxonomy API Catalog API Recommendation API Compliance API Logistics API Finances API(Alpha) Negotiation API Sell Feed API Marketing Ads API Account API Inventory API Fulfillment API Marketing Promotion API Analytics API Metadata API Offer API Marketplace Insights API Deal API Marketing API Feed API Browse API Order API Analytics API Key Management API Cancellation API Case Management API Inquiry API Return API Category -Select- Getting Started Sample Code Troubleshooting HowTo's / Best Practices No Value
Language -Select- C# Flex Java JavaScript PHP VB.NET VB6
Format -Select- All XML SOAP JSON Name Value N/A
SDK -Select- .NET Java JavaScript Flax/Flash Mobile - iOS None
Sort by Default Summary New Description Date Updated
Sort order Descending Ascending
Search
Published: July 09 2010, 5:25:00 PM Updated: August 16 2022, 7:15:31 PM
How can I find the condition IDs for a specified category and upload an item with one of the IDs?
Summary Make a call to GetCategoryFeatures to get the available item condition definition, then pass one of the condition ID in AddItem or ReviseItem call.
Here is a sample based on Java SDK to call GetCategoryFeatures. We specified the category to 147285 on US site:
package com.ebay.test; import com.ebay.sdk.ApiAccount; import com.ebay.sdk.ApiContext; import com.ebay.sdk.ApiCredential; import com.ebay.sdk.ApiLogging; import com.ebay.sdk.CallRetry; import com.ebay.sdk.call.GetCategoryFeaturesCall; import com.ebay.soap.eBLBaseComponents.CategoryFeatureType; import com.ebay.soap.eBLBaseComponents.ConditionEnabledCodeType; import com.ebay.soap.eBLBaseComponents.ConditionType; import com.ebay.soap.eBLBaseComponents.DetailLevelCodeType; import com.ebay.soap.eBLBaseComponents.SiteCodeType;
public class AppGetCategoryFeatures {
public static ApiContext createApiContext() {
ApiContext apiContext = new ApiContext(); ApiLogging apiLogging = new ApiLogging(); apiContext.setApiLogging(apiLogging); CallRetry cr = new CallRetry(); cr.setMaximumRetries(3); cr.setDelayTime(1000); // Wait for one second between each retry-call.
String[] apiErrorCodes = new String[] { "502" };
// Set trigger exceptions for CallRetry. cr.setTriggerApiErrorCodes(apiErrorCodes);
// Build a dummy SdkSoapException so that we can get its Class. Class [] tcs = new Class[] { com.ebay.sdk.SdkSoapException. class }; cr.setTriggerExceptions(tcs); apiContext.setCallRetry(cr); apiContext.setTimeout(180000);
ApiCredential cred = new ApiCredential(); apiContext.setApiServerUrl( "https://api.sandbox.ebay.com/wsapi" ); // apiContext.setApiServerUrl("https://api.ebay.com/wsapi"); cred.seteBayToken(YOUR-TOKEN); apiContext.setApiCredential(cred);
return apiContext;
}
private static GetCategoryFeaturesCall getCatFeature(String categoryId, SiteCodeType site) {
GetCategoryFeaturesCall request = new GetCategoryFeaturesCall( createApiContext ());request.setSite(site); request .setDetailLevel( new DetailLevelCodeType[] { DetailLevelCodeType. RETURN_ALL });
request.setCategoryID(categoryId); request.setOutputSelector( new String[] { "Category.ConditionEnabled" , "Category.ConditionValues.Condition.ID" , "Category.ConditionValues.Condition.DisplayName" });
try {
request.getCategoryFeatures();
} catch (Exception e) { e.printStackTrace(); }
return request;
}
public static void main(String[] args) {
GetCategoryFeaturesCall cf = getCatFeature ( "147285" , SiteCodeType. US );
/* * Since we call GetCategoryFeatures for a specified category, so we * just get the first category element here */
CategoryFeatureType feature = cf.getReturnedCategory()[0];
/* * If condition Enabled is disabled, then DO NOT pass conditionID in * AddItem or ReviseItem for this category */
if (feature.getConditionEnabled().equals( ConditionEnabledCodeType. ENABLED )) {
for (ConditionType con : feature.getConditionValues() .getCondition())
System. out .println(con.getID() + " - " + con.getDisplayName()); }
}
}
After run the code, you will see the condition ID definition for this category as:
1000 - New with box
1500 - New without box
1750 - New with defects 3000 - Pre-owned
Then pick up one of the condition ID, say "New". So we have to pass condtionID "1000" in the AddItem or ReviseItem Call:
...
AddItemCall request = new AddItemCall(createApiContext ()); ItemType item = new ItemType(); item.setConditionID(1000);
...
request.setItem(item); request.addItem();
...
How well did this answer your question? Answers others found helpful