2016-04-15 11 views
3

私はC#のAPIを介して既存のeBayアイテムにブランドと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はエラーを返します。

を」アイテム固有のブランドが見つかりません。このリストにブランドを追加し、有効な値を入力してもう一度お試しください。

私は間違っていますか?

ありがとうございました。ありがとう。

enter image description here

エラー: enter image description here

答えて

4

エラーメッセージとしてこう述べています。

The item specific Brand is missing

リクエストにItem.ProductListingDetails.BrandMPNを使用しないでください。代わりに、BandとMPNと呼ばれる2つのItem Specificsを作成する必要があります。

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

それが動作するには、ありがとうございました! – ihorko

3

はここ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); 

      } 
関連する問題