亚马逊MWS在GetMyFeesEstimate上接收MalformedInput

时间:2017-04-11 09:01:32

标签: c# amazon-mws amazon-product-api

我正在尝试使用产品API部分客户端库从我的.Net应用程序访问亚马逊MWS API - C#(https://developer.amazonservices.com/doc/products/products/v20111001/cSharp.html/138-8219342-3408216

一切正常,但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>

有人知道如何让它发挥作用吗?

1 个答案:

答案 0 :(得分: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);
    }