Search code examples
javascriptnode.jsamazon-product-apiamazon-product-advertising-api

Trouble forming Amazon Product Advertising API's CartCreate Items object in Node


I'm using node-apac (https://github.com/dmcquay/node-apac) to communicate with Amazon's Product Advertising API, but I'm having trouble forming the Items object for the CartCreate operation. Amazon's just returning formatting errors no matter how I do it.

The object I'm sending to the operation looks like this:

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

I've also tried sending the object as arrays:

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

But it seems to dislike the structure of the object no matter how I create it. In the second example, for instance, the error returned is "Your request is missing required parameters. Required parameters include Item."

Any advice would be massively appreciated.

Cheers


Solution

  • For anyone who finds this, I managed to get it working. The keys were named wrong. It should have been:

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