dmcquay / node-apac

node-apac - Node.js client for the Amazon Product Advertising API, including support of Request Signatures
MIT License
499 stars 111 forks source link

Trouble forming CartCreate Items object #49

Closed beclamide closed 8 years ago

beclamide commented 9 years ago

Hi,

Firstly thanks for the great Node module, it's really easy to use and I'm flying through this project!

I've hit a buffer though, I'm struggling to construct the Items object for the CartCreate operation. Amazon keeps telling me I've formatted the object incorrectly. It's driving me mad and I can't find anything about it in the documentation.

The first way I tried was with a literal object:

'Items': {
      'Item': {
            'OfferListingId': itemId,
            'Quantity': quantity
      }
}

But that didn't work. It said there were required parameters missing. I think in this case it was OfferListingId, and Quantity.

So I tried it again using Arrays:

'Items': [{
      'Item': [{
            'OfferListingId': itemId,
            'Quantity': quantity
      }]
}]

But no dice. Amazon just returned a "Your request is missing required parameters. Required parameters include Item." error.

I appreciate it's probably not specifically a node-apac issue, so I've asked on stackoverflow too (http://stackoverflow.com/questions/27469122/trouble-forming-amazon-product-advertising-apis-cartcreate-items-object-in-node)

Any help would be greatly appreciated.

Many thanks

beclamide commented 8 years ago

For anyone who finds this, I managed to get it working. The keys were simply named incorrectly (not a lot of documentation from Amazon to be honest). It should have been:

var data = {
  'Item.1.ASIN': itemId,
  'Item.1.Quantity': quantity
}