如果我通过草稿板向MWS提交请求(
AmazonServices/Scratchpad
),
它是成功的,我可以查看成功请求的详细信息。特别是,请求上的时间戳如下所示:
&Timestamp=2018-08-14T18%3A30%3A02Z
如果我按字面上的意思取下这个时间戳,并尝试在代码中使用它来做出相同的准确请求,我会得到一个错误:
<Message>Timestamp 2018-08-14T18%3A30%3A02Z must be in ISO8601
format</Message>\n
下面是我要放入的函数:(一些字符在敏感参数中发生了更改)
exports.sendRequest = () => {
return agent
.post('https://mws.amazonservices.com/Products/2011-10-01')
.query({
AWSAccessKeyId: encodeURIComponent('BINAJO5TPTZ5TTRLNGQA'),
Action: encodeURIComponent('GetMatchingProductForId'),
SellerId: encodeURIComponent('H1N1R958BK8TTH'),
SignatureVersion: encodeURIComponent('2'),
Timestamp: '2018-08-14T18%3A30%3A02Z',
Version: encodeURIComponent('2011-10-01'),
Signature: encodeURIComponent(exports.generateSignature()),
SignatureMethod: encodeURIComponent('HmacSHA256'),
MarketplaceId: encodeURIComponent('ATVPDKIKX0DER'),
IdType: encodeURIComponent('UPC'),
'IdList.Id.1': encodeURIComponent('043171884536')
})
.then(res => {
console.log('here is the response');
console.log(res)
})
.catch(error => {
console.log('here is the error');
console.log(error);
})
}
更奇怪的是,这是请求发送到的路径:
path: '/Products/2011-10-01?
awsacesskeyid=binajo5zptz5ytpngqa&action=getmatchingproductforid&sellerid=h1n1r958et8thh&signatureReversion=2×tamp=2018-08-14t18%253a30%253a02z&version=2011-10-01&signature=lwzn5of9nwcagoob0jhabymeqt31m6y93qhux0d%252bck8%253d&signaturemethod=hmacsha256&marketplaceid=atvpdkikx0der&idtype=upc&idlist.id.1=043171884536',
时间戳与我在查询中放置的时间戳不同。为什么会这样?