亚马逊 MWS API 请求错误
Posted
技术标签:
【中文标题】亚马逊 MWS API 请求错误【英文标题】:Amazon MWS API request error 【发布时间】:2017-04-12 14:48:01 【问题描述】:我在使用 mws-sdk-promises 库时遇到了一些问题 (https://www.npmjs.com/package/mws-sdk-promises)。
我收到此错误。我已经仔细检查了所有插件信息是否正确。我不知道为什么我会得到这个块。我该如何解决这个问题?
--------
"ErrorResponse":"$":"xmlns":"https://mws.amazonservices.com/Orders/2013-09-01","Error":["Type":["Sender"],"Code":["SignatureDoesNotMatch"],"Message":["The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."]],"RequestID":["e262570a-f493-4d3b-9183-88e528225599"]
--------
var express = require('express');
var router = express.Router();
var MWS = require('mws-sdk-promises'),
client = new MWS.Client(process.env.AWS_ACCESS_KEY_ID, process.env.SECRET_ACCESS_KEY, process.env.MERCHANT_SELLER_ID, ),
MarketplaceId = process.env.MARKET_PLACE_ID;
router.get('/', function(req, res, next)
function getListOrders(client, args)
var req = MWS.Orders.requests.ListOrders();
req.set('CreatedAfter', args.CreatedAfter);
req.set('CreatedBefore', args.CreatedBefore);
req.set('LastUpdatedAfter', args.LastUpdatedAfter);
req.set('MarketplaceId', args.MarketplaceId);
req.set('LastUpdatedBefore', args.LastUpdatedBefore);
req.set('OrderStatus', args.OrderStatus);
req.set('FulfillmentChannel', args.FulfillmentChannel);
req.set('PaymentMethod', args.PaymentMethod);
req.set('BuyerEmail', args.BuyerEmail);
req.set('SellerOrderId', args.SellerOrderId);
req.set('MaxResultsPerPage', args.MaxResultsPerPage);
return client.invoke(req);
var date = new Date();
getListOrders(client,
MarketplaceId: MarketplaceId,
MaxResultsPerPage: 10,
CreatedAfter: new Date(2016, 09, 1),
CreatedBefore: new Date(2015, 1, 31)
)
.catch(function(error)
console.error("-----ERROR");
console.error(error);
)
.then(function(RESULT)
console.log("--------RESULT");
console.log(JSON.stringify(RESULT));
console.log("--------");
);
);
module.exports = router;
【问题讨论】:
【参考方案1】:您确定您的 ENV 变量是正确的吗?这似乎是一个身份验证错误。
仔细检查这些环境变量:
AWS_ACCESS_KEY_ID
SECRET_ACCESS_KEY
MERCHANT_SELLER_ID
您的时间和时区必须正确。你也检查过这个吗?
【讨论】:
以上是关于亚马逊 MWS API 请求错误的主要内容,如果未能解决你的问题,请参考以下文章
亚马逊 MWS API 中的 RequestThrottling 问题