2017-04-11 164 views
1

我想從我的.NET應用程序訪問亞馬遜MWS API,使用產品API部分客戶端庫接收MalformedInput - C#(https://developer.amazonservices.com/doc/products/products/v20111001/cSharp.html/138-8219342-3408216亞馬遜MWS上GetMyFeesEstimate

一切工作正常,除了GetMyFeesEstimate電話。 我用這個方法從例如:

public GetMyFeesEstimateResponse InvokeGetMyFeesEstimate() 
    { 
     // Create a request. 
     GetMyFeesEstimateRequest request = new GetMyFeesEstimateRequest(); 
     string sellerId = "example"; 
     request.SellerId = sellerId; 
     string mwsAuthToken = "example"; 
     request.MWSAuthToken = mwsAuthToken; 
     FeesEstimateRequestList feesEstimateRequestList = new FeesEstimateRequestList(); 
     request.FeesEstimateRequestList = feesEstimateRequestList; 
     return this.client.GetMyFeesEstimate(request); 
    } 

我添加項目FeesEstimateRequestList這樣的:

feesEstimateRequestList.FeesEstimateRequest.Add(new FeesEstimateRequest 
     { 
      MarketplaceId = marketplaceId, 
      IdType = "ASIN", 
      IdValue = "B0078LENZC", 
      PriceToEstimateFees = new PriceToEstimateFees { ListingPrice = new MoneyType { Amount = 30.49M, CurrencyCode = "GBP" }, Shipping = new MoneyType { Amount = 3.5M, CurrencyCode = "GBP" }, Points = new Points { PointsNumber = 0 } }, 
      Identifier = "request_" + Guid.NewGuid().ToString(), 
      IsAmazonFulfilled = false 
     }); 

但不斷得到MalformedInput錯誤,沒有消息說明什麼是錯的:

<ErrorResponse 
xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01"> 
<Error> 
    <Type>Sender</Type> 
    <Code>MalformedInput</Code> 
</Error> 
<RequestId>f79b9147-90d7-4ea2-b51c-d6c37c6a1bd0</RequestId> 
</ErrorResponse> 

有人有任何想法如何使其工作?

回答

0

我已經找到解決方案:

由於我的操作系統區域設置,在價格小數點分隔已經被轉換參數字符串時,設置爲逗號,而不是的。

我不得不修改MwsAQCall類的方法putValue這樣的:

private void putValue(object value) 
    { 
     if (value==null) 
     { 
      return; 
     } 
     if (value is IMwsObject) 
     { 
      parameterPrefix.Append('.'); 
      (value as IMwsObject).WriteFragmentTo(this); 
      return; 
     } 
     string name = parameterPrefix.ToString(); 
     if (value is DateTime) 
     { 
      parameters.Add(name, MwsUtil.GetFormattedTimestamp((DateTime)value)); 
      return; 
     } 
     string valueStr = value.ToString(); 
     if (value is decimal) 
     { 
      valueStr = valueStr.Replace(",", "."); 
     } 
     if (valueStr==null || valueStr.Length==0) 
     { 
      return; 
     } 
     if (value is bool) 
     { 
      valueStr = valueStr.ToLower(); 
     } 
     parameters.Add(name, valueStr); 
    }