繁体   English   中英

如何在现有的易趣物品上添加品牌?

[英]How to add brand to existing eBay item?

在我的应用程序中,我想通过C#上的API将Brand和MPN添加到现有的eBay项目中,因此,我运行代码:

        string eCommerceID = (dr["eCommerceID"] ?? "").ToString().Trim();
        string upc = (dr["UPC"] ?? "").ToString().Trim();
        string manufacturerName = (dr["ManufacturerName"] ?? "").ToString().Trim();
        string brandMPN = (dr["BrandMPN"] ?? "").ToString().Trim();

        ReviseItemRequestType reviseItemRequestType = new ReviseItemRequestType();
        reviseItemRequestType.Version = version;
        reviseItemRequestType.Item = new ItemType();
        reviseItemRequestType.Item.ItemID = eCommerceID;
        reviseItemRequestType.Item.ProductListingDetails = new ProductListingDetailsType();
        reviseItemRequestType.Item.ProductListingDetails.UPC = upc;

        reviseItemRequestType.Item.ProductListingDetails.BrandMPN = new BrandMPNType();
        reviseItemRequestType.Item.ProductListingDetails.BrandMPN.Brand = manufacturerName;
        reviseItemRequestType.Item.ProductListingDetails.BrandMPN.MPN = brandMPN;

        ReviseItemResponseType reviseItemResponseType = ebayService.ReviseItem(reviseItemRequestType);

但是当我执行这段代码时,eBay会返回错误:

“特定商品品牌缺失。将品牌添加到此商家信息中,输入有效值,然后重试。”

我做错了什么?

感谢任何帮助。 谢谢。

在此输入图像描述

错误: 在此输入图像描述

正如错误消息所示:

特定商品品牌缺失

请勿在请求中使用Item.ProductListingDetails.BrandMPN 相反,您需要创建两个名为Band和MPN的Item Specifics

<ItemSpecifics>
    <NameValueList>
        <Name>Brand</Name>
        <Value>[BRAND VALUE]</Value>
    </NameValueList>
    <NameValueList>
        <Name>MPN</Name>
       <Value>[MPN VALUE]</Value>
    </NameValueList>
</ItemSpecifics>

这是C#解决方案的复制粘贴代码片段。

ItemType itemType = new ItemType();   // = class eBay.Service.Core.Soap.ItemType
Int32 condCodeAsInt = 1000; // upto you to derrive this from your use case.
String myBrandValue = "Some BRAND";
String myMpnValue = "some MPN"; 
String myUpcValue = "Does not apply";

....

//if condition is "New" or "New with Details" then we need to set extra REQUIRED fields

            if (condCodeAsInt == 1000 || condCodeAsInt == 1500)
            {

                //if it is "new" then remove inputted desc text completely REQUIRED
                if (condCodeAsInt == 1000)
                {
                    itemType.ConditionDescription = "";
                }

                // set UPC value HERE, not in ItemSpecifics. 
                ProductListingDetailsType pldt =  new ProductListingDetailsType();
                pldt.UPC = myUpcValue;

                itemType.ProductListingDetails = pldt;

                //init Item specifics ( and set BRAND and MPN )
                itemType.ItemSpecifics = new NameValueListTypeCollection();

                //brand
                NameValueListType nvBrand = new NameValueListType();
                nvBrand.Name = "Brand";
                StringCollection brandStringCol = new StringCollection();
                brandStringCol.Add(myBrandValue);
                nvBrand.Value = brandStringCol;

                itemType.ItemSpecifics.Add(nvBrand);

                //MPN
                NameValueListType nvMpn = new NameValueListType();
                nvMpn.Name = "MPN";
                StringCollection mpnStringCol = new StringCollection();
                mpnStringCol.Add(myMpnValue);
                nvMpn.Value = mpnStringCol;

                itemType.ItemSpecifics.Add(nvMpn);

            }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM