C# 如何将品牌添加到现有易趣项目?

C# 如何将品牌添加到现有易趣项目?,c#,asp.net,ebay-api,C#,Asp.net,Ebay Api,在我的应用程序中,我希望通过C#上的API将品牌和MPN添加到现有易趣项目中,因此,我运行代码: string eCommerceID = (dr["eCommerceID"] ?? "").ToString().Trim(); string upc = (dr["UPC"] ?? "").ToString().Trim(); string manufacturerName = (dr["ManufacturerName"] ?? "").ToSt

在我的应用程序中,我希望通过C#上的API将品牌和MPN添加到现有易趣项目中,因此,我运行代码:

        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);
但当我执行此代码时,易趣返回错误:

缺少特定于项目的品牌。请将品牌添加到此列表,输入有效值,然后重试

我做错了什么

谢谢你的帮助。谢谢

错误:

如错误消息所示:

缺少特定于项目的品牌

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

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

烙印
[品牌价值]
MPN
[MPN值]

这里是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);

            }