Я пытаюсь получить UPC предмета, возвращенного вызовом GetSellerList
, используя eBay Trading API.
Я могу успешно выполнить вызов API, используя этот код:
public void getSellerItemsList() throws ApiException, SdkException, Exception
{
String EBayProfile = "XXXXXXXXXXXX";
String sellerID = "XXXXXXXXXXXXXX";
ApiContext apiContext = getAPIContext(EBayProfile);
GetSellerListCall getSellerList = new GetSellerListCall ();
getSellerList.setApiContext(apiContext);
DetailLevelCodeType[] detailLevelCodeType = new DetailLevelCodeType[1];
detailLevelCodeType[0] = DetailLevelCodeType.RETURN_ALL;
getSellerList.setDetailLevel(detailLevelCodeType);
Calendar fromTime = Calendar.getInstance();
fromTime.add(Calendar.DAY_OF_MONTH, -3);
Calendar toTime = Calendar.getInstance();
toTime.setTime(Calendar.getInstance().getTime());
TimeFilter startTimeFilter = new TimeFilter(fromTime, toTime);
getSellerList.setStartTimeFilter(startTimeFilter);
getSellerList.setUserID(sellerID);
getSellerList.setEnableCompression(true);
WarningLevelCodeType warningLevel = WarningLevelCodeType.HIGH;
getSellerList.setWarningLevel(warningLevel);
PaginationType paginationType = new PaginationType();
paginationType.setEntriesPerPage(199);
paginationType.setPageNumber(1);
ItemType[] items = getSellerList.getEntireSellerList();
for (ItemType item : items) {
System.out.println("\nTitle: " + item.getTitle());
// For some reason this value is always equal to null (never prints)
if (item.getAttributeArray() != null) {
AttributeArrayType attributeType = item.getAttributeArray();
System.out.println("Attributes length: " + attributeType.getAttributeLength());
}
// For some reason this value is always equal to null (never prints)
if (item.getProductListingDetails() != null) {
UPC = item.getProductListingDetails().getUPC();
System.out.println("UPC: " + UPC);
}
// For some reason this value is always equal to null (never prints)
if (item.getVariations() != null) {
VariationsType itemVariations = item.getVariations();
for (int x = 0; x < itemVariations.getVariationLength(); x++) {
VariationType variation = itemVariations.getVariation(x);
VariationProductListingDetailsType variationListingDetails = variation.getVariationProductListingDetails();
UPC = variationListingDetails.getUPC(); // UPC always missing
}
}
// For some reason this value is always equal to null (never prints)
if (item.getItemSpecifics() != null) {
NameValueListArrayType itemSpecifics = item.getItemSpecifics();
NameValueListType[] nameValueList = itemSpecifics.getNameValueList();
}
}
}
}
Call выполняется успешно, но UPC пуст (независимо от того, где я пытаюсь извлечь его, как видно из предыдущего кода).
Документы eBay четко указывают, что этот вызов возвращает UPC.
Что я делаю не так?