ebusinessdirect / mws-simple

nodejs Amazon MWS API in 100 lines of code
MIT License
8 stars 11 forks source link

Signature issue when trynig to submit feed #4

Open LongneckJohn opened 7 years ago

LongneckJohn commented 7 years ago

I need some help. Here is my code. I am able to use the package for orders and reports an am now trying to use feed to add products. Any ideas what I am doing wrong or is this a bug?


let mws = require('mws-simple')({ accessKeyId: ourAmazonController.awsAccessKeyId, secretAccessKey: ourAmazonController.secret, merchantId: ourAmazonController.sellerId });

var ourFeedContent = `
                  <?xml version="1.0" ?>
                    <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
                      <Header>
                        <DocumentVersion>1.01</DocumentVersion>
                        <MerchantIdentifier>M_SELLER_354577</MerchantIdentifier>
                      </Header>
                      <MessageType>Product</MessageType>
                      <PurgeAndReplace>true</PurgeAndReplace>
                      <Message>
                        <MessageID>1</MessageID>
                        <OperationType>Update</OperationType>
                        <Product>
                          <SKU>JDLtestJDL</SKU>
                          <ProductTaxCode>A_GEN_TAX</ProductTaxCode>
                          <LaunchDate>2025-07-26T00:00:01</LaunchDate>
                          <DescriptionData>
                            <Title>Lyric 500 tc Queen Flat Sheet, Ivory</Title>
                            <Brand>Test Brand</Brand>
                            <Description>
                              This is a test product and is not for purchase.
                            </Description>
                            <BulletPoint>test bullet 1</BulletPoint>
                            <BulletPoint>test bullet 2</BulletPoint>
                            <Manufacturer>test manufacturer</Manufacturer>
                            <SearchTerms>test search term</SearchTerms>
                            <ItemType>test item type</ItemType>
                            <IsGiftWrapAvailable>false</IsGiftWrapAvailable>
                            <IsGiftMessageAvailable>false</IsGiftMessageAvailable>
                          </DescriptionData>
                          <ProductData>
                            <Home>
                              <Parentage>variation-parent</Parentage>
                              <VariationData>
                                <VariationTheme>Size-Color</VariationTheme>
                              </VariationData>
                              <Material>cotton</Material>
                              <ThreadCount>500</ThreadCount>
                            </Home>
                          </ProductData>
                      </Product>
                    </Message>
                    <Message>
                  </AmazonEnvelope>
                  `
;

let submitFeed = {
  feedContent: ourFeedContent,
  query: {
    Action: 'SubmitFeed',
    FeedType: '_POST_PRODUCT_DATA_',
    'MarketplaceIdList.Id.1': ourAmazonController.marketplaceId,
    Version: '2009-01-01'
  }
};

mws.request(submitFeed, function(e, result) {
});

Future = Npm.require('fibers/future');
var myFuture = new Future();

mws.request(submitFeed, function(error, results) {
  if ( error ) {
    myFuture.return(error);
  } else {
    myFuture.return(results);
  }
  //consoleLogObject("results", results);

});

return myFuture.wait(); // wait for the mws http call to return

The above generates this response: { -"ErrorResponse": { -"$": { "xmlns": "http://mws.amazonaws.com/doc/2009-01-01/" }, -"Error": [ -{ -"Type": [ "Sender" ], -"Code": [ "SignatureDoesNotMatch" ], -"Message": [ "The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details." ] } ], +"RequestID": [ … ] } }

ebusinessdirect commented 7 years ago

Got this, will check it out.

jleiken commented 7 years ago

+1 I'm having the same issue. I have two files using this package, one which is simple and just uses the package to explore the API. The other is much longer and among other packages. It's still working for me in the smaller file but not in the larger one. Calls were working for me in the larger one until today.

jleiken commented 7 years ago

Resolved. I wasn't including a CreatedAfter or CreatedBefore parameter.