As you can see, although I have specified my date range for StartDate and EndDate in Dec 2017, the response returned from Amazon changed it into Jan 2018
I took a look at mws.js and saw this code block converting values to valid ISO timestamp.
// Handles the actual setting based on type
var setValue = function setValue(name, val) {
if (p.type == 'Timestamp') {
self.params[name].value = val.toISOString();
} else if (p.type == 'Boolean') {
self.params[name].value = val ? 'true' : 'false';
} else {
self.params[name].value = val;
}
};
new Date().toISOString returns a new date in ISO format: 2017-12-18T05:44:50.476Z
However for RequestReport API, StartDate and EndDate should be in this format 2018-01-15T16:00:00+00:00 as seen from Amazon's response.
Using that timestamp, I modified mws.js to not convert values to ISOString, I have managed to successfully get the date range I wanted.
// Handles the actual setting based on type
var setValue = function setValue(name, val) {
if (p.type == 'Timestamp') {
self.params[name].value = val; // Remove to ISO
} else if (p.type == 'Boolean') {
self.params[name].value = val ? 'true' : 'false';
} else {
self.params[name].value = val;
}
};
// Update my API to take in date string values
app.get('/requestOrdersReport', async (req, res) => {
try {
const result = await requestOrdersReport(mwsClient, {
ReportType: '_GET_FLAT_FILE_ORDERS_DATA_',
StartDate: '2017-12-10T00:00:00+00:00',
EndDate: '2017-12-15T00:00:00+00:00'
});
res.send(result);
} catch (error) {
console.log(error);
}
});
// Response from Amazon
{
"RequestReportResponse": {
"$": {
"xmlns": "http://mws.amazonaws.com/doc/2009-01-01/"
},
"RequestReportResult": [
{
"ReportRequestInfo": [
{
"ReportType": [
"_GET_FLAT_FILE_ORDERS_DATA_"
],
"ReportProcessingStatus": [
"_SUBMITTED_"
],
"EndDate": [
"2017-12-15T00:00:00+00:00"
],
"Scheduled": [
"false"
],
"ReportRequestId": [
"REQUEST_ID"
],
"SubmittedDate": [
"2017-12-18T05:53:25+00:00"
],
"StartDate": [
"2017-12-10T00:00:00+00:00"
]
}
]
}
],
"ResponseMetadata": [
{
"RequestId": [
"REQUEST_ID"
]
}
]
}
}
My response for this request is as follow:
As you can see, although I have specified my date range for
StartDate
andEndDate
in Dec 2017, the response returned from Amazon changed it into Jan 2018I took a look at mws.js and saw this code block converting values to valid ISO timestamp.
new Date().toISOString
returns a new date in ISO format:2017-12-18T05:44:50.476Z
However for RequestReport API,
StartDate
andEndDate
should be in this format2018-01-15T16:00:00+00:00
as seen from Amazon's response.Using that timestamp, I modified mws.js to not convert values to ISOString, I have managed to successfully get the date range I wanted.