Closed muhammadali7768 closed 3 years ago
Maybe it is gziped?
yes i fixed this by making axios call. I was using a plugin which returns the response as a string and there was some bytes missing i think thats why i was getting scrambled data. With the axios call now i can save the file as a zip and .xlsx both and also can return the file to the browser.
return axios({
method: 'post',
url: url,
data: requestParameters(action, token, sellerId, {ReportId: reportId}),
responseType: 'stream'
})
.then(async response => {
response.data.pipe(res)
})
.catch(error => {
if (error.response) {
console.log(error.response.data)
console.log(error.response.status);
console.log(error.response.headers);
}
})
Is this something we can fix in the MWS package?
I think yes. MWS package is working fine for flat file reports but i am getting scramble data for the report types "_RFQD_BULKDOWNLOAD" and "_FEE_DISCOUNTSREPORT" which are compressed xlsx files.
When i saved "RFQD_BULK_DOWNLOAD" and "FEE_DISCOUNTS_REPORT" reports as a zip using axios. The zip file looks like this.
But i can save these reports directly as .xlsx files too.
Some APIs send back UTF8 encoded strings instead of raw binary data. Since the ZIP format uses byte sequences that could be interpreted as unicode characters, the result will not be a valid ZIP.
Note that some services like AWS Lambda perform some UTF8 transform on the response by default, and some server-side configuration may be needed
I am getting a xlsx file from Amazon, the attached image shows the response headers and body.
I am writing the file to desk using the following code
When i open the file the content is not in readable form. Each cell has a string of 000000000. Following is the screenshot of the file