claytondus / Claytondus.AmazonMWS

.NET Standard fork of Amazon MWS client
https://developer.amazonservices.com/
Apache License 2.0
33 stars 12 forks source link

Malformed Input #9

Open kevinvenclovas opened 5 years ago

kevinvenclovas commented 5 years ago

Hello, i try to use the GetMyFeesEstimate API and get every time a Malformed error. The critical line is the Amount = 12.99M with 13 it works fine but i need the exect value.

FeesEstimateRequestList feesEstimateRequestList = new FeesEstimateRequestList()
            {
                FeesEstimateRequest = new List<FeesEstimateRequest>()
                {
                    new FeesEstimateRequest()
                    {
                        MarketplaceId = "A1PA6795UKMFR9",
                        IdType = "ASIN",
                        IdValue = "B07P91KLRM",
                        IsAmazonFulfilled = false,
                        Identifier = "request1",
                        PriceToEstimateFees = new PriceToEstimateFees()
                        {
                            ListingPrice = new MoneyType()
                            {
                                Amount = 12.99M,
                                CurrencyCode = "EUR",
                            },
                        }
                    }
                }
            };
claytondus commented 4 years ago

I don't have an EUR account, but I was just able to complete this request:

FeesEstimateRequest = new List<FeesEstimateRequest>()
                {
                    new FeesEstimateRequest()
                    {
                        MarketplaceId = "ATVPDKIKX0DER",
                        IdType = "ASIN",
                        IdValue = "B016W63ZYS",
                        IsAmazonFulfilled = false,
                        Identifier = "request1",
                        PriceToEstimateFees = new PriceToEstimateFees()
                        {
                            ListingPrice = new MoneyType()
                            {
                                Amount = 12.99M,
                                CurrencyCode = "USD",
                            },
                        }
                    }
                }
<GetMyFeesEstimateResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01"><GetMyFeesEstimateResult><FeesEstimateResultList><FeesEstimateResult><Status>Success</Status><FeesEstimateIdentifier><MarketplaceId>ATVPDKIKX0DER</MarketplaceId><SellerId>A2EIAUMHCIBDMM</SellerId><IdType>ASIN</IdType><IdValue>B016W63ZYS</IdValue><IsAmazonFulfilled>False</IsAmazonFulfilled><PriceToEstimateFees><ListingPrice><CurrencyCode>USD</CurrencyCode>*<Amount>12.99</Amount>*</ListingPrice></PriceToEstimateFees><SellerInputIdentifier>request1</SellerInputIdentifier></FeesEstimateIdentifier><FeesEstimate><TimeOfFeesEstimation>12/24/2019 17:31:52</TimeOfFeesEstimation><TotalFeesEstimate><CurrencyCode>USD</CurrencyCode><Amount>3.75</Amount></TotalFeesEstimate><FeeDetailList><FeeDetail><FeeType>ReferralFee</FeeType><FeeAmount><CurrencyCode>USD</CurrencyCode><Amount>1.95</Amount></FeeAmount><FeePromotion><CurrencyCode>USD</CurrencyCode><Amount>0.00</Amount></FeePromotion><FinalFee><CurrencyCode>USD</CurrencyCode><Amount>1.95</Amount></FinalFee></FeeDetail><FeeDetail><FeeType>VariableClosingFee</FeeType><FeeAmount><CurrencyCode>USD</CurrencyCode><Amount>1.80</Amount></FeeAmount><FeePromotion><CurrencyCode>USD</CurrencyCode><Amount>0.00</Amount></FeePromotion><FinalFee><CurrencyCode>USD</CurrencyCode><Amount>1.80</Amount></FinalFee></FeeDetail><FeeDetail><FeeType>PerItemFee</FeeType><FeeAmount><CurrencyCode>USD</CurrencyCode><Amount>0.00</Amount></FeeAmount><FeePromotion><CurrencyCode>USD</CurrencyCode><Amount>0.00</Amount></FeePromotion><FinalFee><CurrencyCode>USD</CurrencyCode><Amount>0.00</Amount></FinalFee></FeeDetail></FeeDetailList></FeesEstimate></FeesEstimateResult></FeesEstimateResultList></GetMyFeesEstimateResult><ResponseMetadata><RequestId>5ccfb172-de7f-48d7-8607-8f3856db9d6f</RequestId></ResponseMetadata></GetMyFeesEstimateResponse>
kevinvenclovas commented 4 years ago

Hi, now i got the issue after come back again.

You need to recode the WriteFragmentTo in the Claytondus.AmazonMWS.Products.Model.MoneyType class. With the german localization the ".ToString" function convert the decimal "Amount" -> 12.99M to 12,99 but amazon need the dot version 12.99 .

So you need to change : writer.Write("Amount", _amount);

to

writer.Write("Amount", _amount?.ToString(CultureInfo.InvariantCulture));