首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Java Trading API中通过GetSellerList调用获取项目的UPC [ eBay ]

如何在Java Trading API中通过GetSellerList调用获取项目的UPC [ eBay ]
EN

Stack Overflow用户
提问于 2018-05-15 00:40:03
回答 2查看 298关注 0票数 1

我正在尝试使用eBay交易应用程序接口获取由GetSellerList调用返回的项目的UPC。

我可以使用以下代码成功执行API调用:

代码语言:javascript
运行
复制
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。

我做错了什么?

EN

回答 2

Stack Overflow用户

发布于 2018-05-16 15:50:49

GetSellerList不包括项目详细信息。

您必须结合使用eBay购物API call- GetSingleItem和IncludeSelector - ItemSpecifics来获取GetSellerList结果中每一项的UPC

票数 0
EN

Stack Overflow用户

发布于 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"。不管怎样,它仍然有效。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50335183

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档