我正在尝试使用eBay交易应用程序接口获取由GetSellerList
调用返回的项目的UPC。
我可以使用以下代码成功执行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();
}
}
}
}
调用成功执行,但UPC为空(无论我尝试从何处提取它,如前面的代码所示)。
eBay Docs清楚地声明此调用返回UPC。
我做错了什么?
发布于 2018-05-16 15:50:49
GetSellerList不包括项目详细信息。
您必须结合使用eBay购物API call- GetSingleItem和IncludeSelector - ItemSpecifics来获取GetSellerList结果中每一项的UPC
发布于 2021-02-11 07:20:35
“此字段不再在GetSingleItem或GetMultipleItems调用中返回。要查看列表(或多种变体列表中的产品变体)中的产品的eBay产品ID (也称为ePID)或全球贸易项目编号(UPC、EAN、ISBN或MPN),请使用交易API的GetItem调用。”
https://developer.ebay.com/devzone/shopping/docs/callref/getsingleitem.html
但并非所有用户都可以共享交易应用编程接口的GetItem。您只能看到您自己的项目
对于MPN,你可以尝试这样的调用:"http://open.api.ebay.com/shopping?callname=GetSingleItem&IncludeSelector=ItemSpecifics&responseencoding=XML&appid=XXXX&siteid=0&version=967&ItemID=111111111111"。不管怎样,它仍然有效。
https://stackoverflow.com/questions/50335183
复制相似问题