bhushankummar / amazon-mws

Amazon MWS NodeJS Wrapper
MIT License
197 stars 78 forks source link

GetMyFeesEstimate returns "invalid xml" #115

Open fr3shn3ss opened 4 years ago

fr3shn3ss commented 4 years ago

It won't work for >4 ASINs. <4 works great though. Scratchpad works for >4.

Here is my code: //asinList is an array of ASINs var GetMyFeesEstimate = async function (asinList) { var obj = { 'Version': '2011-10-01', 'Action': 'GetMyFeesEstimate', 'SellerId': SellerId, 'MWSAuthToken': MWSAuthToken, 'FeesEstimateRequestList.FeesEstimateRequest.1.MarketplaceId': 'ATVPDKIKX0DER', 'FeesEstimateRequestList.FeesEstimateRequest.1.IdType': 'ASIN' }

//adding each asin from asinList to obj >> ASINList.ASIN.X
for (var i = 1; i <= asinList.length; i++) {
    obj['FeesEstimateRequestList.FeesEstimateRequest.' + i + '.MarketplaceId'] = MarketplaceId;
    obj['FeesEstimateRequestList.FeesEstimateRequest.' + i + '.IdType'] = 'ASIN';
    obj['FeesEstimateRequestList.FeesEstimateRequest.' + i + '.IdValue'] = asinList[i - 1];
    obj['FeesEstimateRequestList.FeesEstimateRequest.' + i + '.IsAmazonFulfilled'] = 'true';
    obj['FeesEstimateRequestList.FeesEstimateRequest.' + i + '.Identifier'] = 'Hello';
    obj['FeesEstimateRequestList.FeesEstimateRequest.' + i + '.PriceToEstimateFees.ListingPrice.CurrencyCode'] = 'USD';
    obj['FeesEstimateRequestList.FeesEstimateRequest.' + i + '.PriceToEstimateFees.ListingPrice.Amount'] = '10';
    obj['FeesEstimateRequestList.FeesEstimateRequest.' + i + '.PriceToEstimateFees.Shipping.CurrencyCode'] = 'USD';
    obj['FeesEstimateRequestList.FeesEstimateRequest.' + i + '.PriceToEstimateFees.Shipping.Amount'] = '0';
    obj['FeesEstimateRequestList.FeesEstimateRequest.' + i + '.PriceToEstimateFees.Points.PointsNumber'] = '0';

}

console.log(obj)
try {
    const r = await amazonMws.products.search(obj);
    console.log(JSON.stringify(r))
} catch (e) {
    console.log(e)
}

};

fr3shn3ss commented 4 years ago

@bhushankumarl any ideas? Thanks.

bhushankummar commented 4 years ago

@fr3shn3ss Can you send me an actual error?

fr3shn3ss commented 4 years ago

@bhushankumarl thanks. I just tested again. 4 asins work fine, but 5 throws this error no proxy set (HTTP_PROXY) { Version: '2011-10-01', Action: 'GetMyFeesEstimate', SellerId: 'XXXXXXXXXXXXXXXXXXXXXXX', MWSAuthToken: 'XXXXXXXXXXXXXXXXXXXXXXX', 'FeesEstimateRequestList.FeesEstimateRequest.1.MarketplaceId': 'ATVPDKIKX0DER', 'FeesEstimateRequestList.FeesEstimateRequest.1.IdType': 'ASIN', 'FeesEstimateRequestList.FeesEstimateRequest.1.IdValue': '0735201439', 'FeesEstimateRequestList.FeesEstimateRequest.1.IsAmazonFulfilled': 'true', 'FeesEstimateRequestList.FeesEstimateRequest.1.Identifier': 'Hello', 'FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.CurrencyCode': 'USD', 'FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.Amount': '10', 'FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Shipping.CurrencyCode': 'USD', 'FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Shipping.Amount': '0', 'FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Points.PointsNumber': '0', 'FeesEstimateRequestList.FeesEstimateRequest.2.MarketplaceId': 'ATVPDKIKX0DER', 'FeesEstimateRequestList.FeesEstimateRequest.2.IdType': 'ASIN', 'FeesEstimateRequestList.FeesEstimateRequest.2.IdValue': '0571198775', 'FeesEstimateRequestList.FeesEstimateRequest.2.IsAmazonFulfilled': 'true', 'FeesEstimateRequestList.FeesEstimateRequest.2.Identifier': 'Hello', 'FeesEstimateRequestList.FeesEstimateRequest.2.PriceToEstimateFees.ListingPrice.CurrencyCode': 'USD', 'FeesEstimateRequestList.FeesEstimateRequest.2.PriceToEstimateFees.ListingPrice.Amount': '10', 'FeesEstimateRequestList.FeesEstimateRequest.2.PriceToEstimateFees.Shipping.CurrencyCode': 'USD', 'FeesEstimateRequestList.FeesEstimateRequest.2.PriceToEstimateFees.Shipping.Amount': '0', 'FeesEstimateRequestList.FeesEstimateRequest.2.PriceToEstimateFees.Points.PointsNumber': '0', 'FeesEstimateRequestList.FeesEstimateRequest.3.MarketplaceId': 'ATVPDKIKX0DER', 'FeesEstimateRequestList.FeesEstimateRequest.3.IdType': 'ASIN', 'FeesEstimateRequestList.FeesEstimateRequest.3.IdValue': '8186685596', 'FeesEstimateRequestList.FeesEstimateRequest.3.IsAmazonFulfilled': 'true', 'FeesEstimateRequestList.FeesEstimateRequest.3.Identifier': 'Hello', 'FeesEstimateRequestList.FeesEstimateRequest.3.PriceToEstimateFees.ListingPrice.CurrencyCode': 'USD', 'FeesEstimateRequestList.FeesEstimateRequest.3.PriceToEstimateFees.ListingPrice.Amount': '10', 'FeesEstimateRequestList.FeesEstimateRequest.3.PriceToEstimateFees.Shipping.CurrencyCode': 'USD', 'FeesEstimateRequestList.FeesEstimateRequest.3.PriceToEstimateFees.Shipping.Amount': '0', 'FeesEstimateRequestList.FeesEstimateRequest.3.PriceToEstimateFees.Points.PointsNumber': '0', 'FeesEstimateRequestList.FeesEstimateRequest.4.MarketplaceId': 'ATVPDKIKX0DER', 'FeesEstimateRequestList.FeesEstimateRequest.4.IdType': 'ASIN', 'FeesEstimateRequestList.FeesEstimateRequest.4.IdValue': '1401309747', 'FeesEstimateRequestList.FeesEstimateRequest.4.IsAmazonFulfilled': 'true', 'FeesEstimateRequestList.FeesEstimateRequest.4.Identifier': 'Hello', 'FeesEstimateRequestList.FeesEstimateRequest.4.PriceToEstimateFees.ListingPrice.CurrencyCode': 'USD', 'FeesEstimateRequestList.FeesEstimateRequest.4.PriceToEstimateFees.ListingPrice.Amount': '10', 'FeesEstimateRequestList.FeesEstimateRequest.4.PriceToEstimateFees.Shipping.CurrencyCode': 'USD', 'FeesEstimateRequestList.FeesEstimateRequest.4.PriceToEstimateFees.Shipping.Amount': '0', 'FeesEstimateRequestList.FeesEstimateRequest.4.PriceToEstimateFees.Points.PointsNumber': '0', 'FeesEstimateRequestList.FeesEstimateRequest.5.MarketplaceId': 'ATVPDKIKX0DER', 'FeesEstimateRequestList.FeesEstimateRequest.5.IdType': 'ASIN', 'FeesEstimateRequestList.FeesEstimateRequest.5.IdValue': '0974721719', 'FeesEstimateRequestList.FeesEstimateRequest.5.IsAmazonFulfilled': 'true', 'FeesEstimateRequestList.FeesEstimateRequest.5.Identifier': 'Hello', 'FeesEstimateRequestList.FeesEstimateRequest.5.PriceToEstimateFees.ListingPrice.CurrencyCode': 'USD', 'FeesEstimateRequestList.FeesEstimateRequest.5.PriceToEstimateFees.ListingPrice.Amount': '10', 'FeesEstimateRequestList.FeesEstimateRequest.5.PriceToEstimateFees.Shipping.CurrencyCode': 'USD', 'FeesEstimateRequestList.FeesEstimateRequest.5.PriceToEstimateFees.Shipping.Amount': '0', 'FeesEstimateRequestList.FeesEstimateRequest.5.PriceToEstimateFees.Points.PointsNumber': '0' } { [Error] Type: 'AmazonMwsAPIError', Code: 'GenericError', Message: 'Invalid XML received from the AmazonMws API', StatusCode: 400 }

bhushankummar commented 4 years ago

@fr3shn3ss Thank you for sharing. I will be check soon.

fr3shn3ss commented 4 years ago

@bhushankumarl the issue is also reported here . https://github.com/bhushankumarl/amazon-mws/issues/74#issuecomment-487236200

Thanks :)

akycop commented 4 years ago

Did you ever figure this out? I have the same issue. I can only get up to 4 ASINs using

fr3shn3ss commented 4 years ago

Last time I checked, that was still an issue. My app is now make one call for each ASIN so I don't need it anymore. I think you need to either fix it yourself or switch to a different library

macpatel commented 3 years ago

I too have issues even with 1 ASIN, for me the error is ""Error occurred from AmazonMws API", i checked everything looks good and test the same data on scratchpad as well.

ReyazBeigh commented 2 years ago

was having similar issue with FulfillmentInboundShipment API:

Changed the file /amazon-mws/lib/resources/FulfillmentInboundShipment.js from this :


'use strict';

var AmazonMwsResource = require('../AmazonMwsResource');
var amazonMwsMethod = AmazonMwsResource.method;

module.exports = AmazonMwsResource.extend({

    path: 'FulfillmentInboundShipment',
    search: amazonMwsMethod({
        method: 'GET'
    })

});

To This:

 'use strict';

var AmazonMwsResource = require('../AmazonMwsResource');
var amazonMwsMethod = AmazonMwsResource.method;

module.exports = AmazonMwsResource.extend({

    path: 'FulfillmentInboundShipment',
    search: amazonMwsMethod({
        useBody: false,
        method: 'POST'
    }),
    searchFor: amazonMwsMethod({
        useBody: true,
        method: 'POST'
    })

});

used searchFor to create inbound shipment plan and it worked.

The general problem is this lib. used GET method for some some APIs that support POST method and when the request data goes beyond the URL size limit supported by Amazon, the API starts responding with 400 - bad request.

Hope this helps someone.