Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload does not work for string feed.content (TypeError [ERR_INVALID_ARG_TYPE]: The "list" argument must be an instance of Array. Received type string ('<?xml version="1.0" enco...)) #53

Closed
andrii33 opened this issue Sep 18, 2021 · 1 comment

Comments

@andrii33
Copy link

andrii33 commented Sep 18, 2021

Following the instruction https://www.npmjs.com/package/amazon-sp-api#encrypt-and-upload-feeds
There is an option to upload feed data as a string.
For example:

let feed = {
  content:`<?xml version="1.0" encoding="utf-8"?>
    <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
      <Header>
        <DocumentVersion>1.02</DocumentVersion>
        <MerchantIdentifier>YOUR_MERCHANT_IDENTIFIER</MerchantIdentifier>
      </Header>
      <MessageType>Inventory</MessageType>
      <Message>
        <MessageID>1</MessageID>
        <Inventory>
          <SKU>YOUR_SKU</SKU>
          <Quantity>10</Quantity>
        </Inventory>
      </Message>
    </AmazonEnvelope>`,
  contentType:'text/xml; charset=utf-8'
}
const feedUploadDetails = {
      feedDocumentId: '3d4e42b5-1d6e-44e8-a89c-2abfca0625bb',
      url: 'https://d34o8swod1owfl.cloudfront.net/Feed_101__POST_PRODUCT_DATA_.xml'
}
let res = await sellingPartner.upload(feed_upload_details, feed);

The error is thrown in the case

TypeError [ERR_INVALID_ARG_TYPE]: The "list" argument must be an instance of Array. Received type string ('<?xml version="1.0" enco...)

Looks like on the line (https://github.com/amz-tools/amazon-sp-api/blob/main/lib/SellingPartner.js#L690) we need to have
something like:
content_buffer = Buffer.concat([Buffer.from(feed_content)]);
instead of
content_buffer = Buffer.concat(feed_content);

@amz-tools
Copy link
Owner

@andrii33 Thanks for noticing, we just published a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants