Skip to main content
Published: April 21 2011, 9:40:00 PMUpdated: August 19 2022, 3:00:14 PM

 

  To retrieve Parts Compatibility information for an listing,  you need to specify IncludeItemCompatibilityList flag and set it to true in the GetItem request. (If the item was no listed with compatible applications,  the ItemCompatibilityList node is not returned)

  Here is a Java GetItem sample that illustrates on how to specify IncludeItemCompatibilityList flag in request and iterate through the list of parts compatibility information returned in response to obtain the details for each individual compatible application, consisting of the name- value pair and related compatibility notes.


 

import com.ebay.sdk.*;
import com.ebay.sdk.call.GetItemCall;
import com.ebay.soap.eBLBaseComponents.*;
import org.apache.log4j.Logger;

public class AppGetItem {

    private static final Logger logger = Logger.getLogger(AppGetItem.class);
    private static ApiContext apiContext = new ApiContext();
    private static String TOKEN = "YOUR TOKEN";
    private static String APISERVERURL = "https://api.ebay.com/wsapi";

    public static void main(String[] args) {
         //set api call credential
        ApiCredential cred = new ApiCredential();
        apiContext.setApiCredential(cred);
        apiContext.getApiCredential().seteBayToken(TOKEN);
        //set logging
        ApiLogging apiLogging = new ApiLogging();
        apiContext.setApiLogging(apiLogging);
        apiContext.setApiServerUrl(APISERVERURL);

        GetItemCall getItem = new GetItemCall(apiContext);
        getItem.setItemID("180655903104");
        getItem.setIncludeItemCompatibilityList(true);
        getItem.setIncludeItemSpecifics(true);

        try {
            ItemType item = getItem.getItem();
            NameValueListType[] itemspecifics_nvlist = item.getItemSpecifics().getNameValueList();
            for (NameValueListType itemspecifics_nv : itemspecifics_nvlist) {
                logger.info(" ItemSpecifics NameValueList: ");
                logger.info("   " + itemspecifics_nv.getName());
                for (int i = 0; i < itemspecifics_nv.getValue().length; i++) {
                    logger.info("   " + itemspecifics_nv.getValue(i));
                }
            }

            logger.info("  ");
            ItemCompatibilityType[] list = item.getItemCompatibilityList().getCompatibility();
            if (list != null) {
                for (ItemCompatibilityType itemCampatibility : list) {
                    logger.info("Compatibility: ");
                    NameValueListType[] itemCampatibility_nvlist = itemCampatibility.getNameValueList();
                    for (NameValueListType itemCampatibility_nv : itemCampatibility_nvlist) {
                        logger.info(" ItemCampatibility  NameValueList: ");
                        logger.info("   " + itemCampatibility_nv.getName());
                        for (int i = 0; i < itemCampatibility_nv.getValue().length; i++) {
                            logger.info("   " + itemCampatibility_nv.getValue(i));
                        }
                    }
                }
            }
        } catch (Throwable e) {
            logger.error(e.getMessage(), e);
        } finally {
        }
    }
}

 

 


 

 

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

Got thoughts? Click the feedback button – your insights help us improve!