amz-tools / amazon-sp-api

Amazon Selling Partner API Client
MIT License
238 stars 121 forks source link

Incorrect Header Check error downloading file #268

Open rahulserver opened 10 months ago

rahulserver commented 10 months ago

I get this error when trying to download file using this code in amazon-sp-api v1.0.4:

 let sellingPartner = new SellingPartnerAPI(this.configOptions);
      let res = await sellingPartner.callAPI({
        api_path: `/reports/2020-09-04/documents/${args.documentId}`,
        method: 'GET'
      });
      let report = await sellingPartner.download(res, {
        json: true
      });
Error: incorrect header check
    at genericNodeError (node:internal/errors:956:15)
    at wrappedFn (node:internal/errors:510:14)
    at Zlib.zlibOnError [as onerror] (node:zlib:189:17)
    at Zlib.callbackTrampoline (node:internal/async_hooks:130:17) {
  errno: -3,
  code: 'Z_DATA_ERROR'
}

This only seems to occur for some of the documentIds. To be specific, for this document id I got above error:

amzn1.spdoc.1.4.na.2b611da1-4893-46e2-8f82-5bbc9ed207d1.T3CEV4LAOA16EL.18200

Why is it happening and how do I fix it?

rahulserver commented 10 months ago

I downgraded my version to 0.7.10 and it works fine. So the issue seems to be only in latest version(and probably v1+)