item_lookup with multiple ItemId's

Hi, I've been using this API for a few days now and love it, thanks for the great work!

I recently encountered behavior that may be an issue and hoping someone here may know ...

I am doing ItemLookup with multiple ItemId's, but if any of the ItemId's are not found on the Amazon site than the whole request fails. I should mention that I added an IdType parameter to item_lookup so I could lookup an item with UPC (pretty straightforward).
prodResult = api.item_lookup(UPCstr, IdType='UPC', SearchIndex=searchIndex, ResponseGroup='Offers,ItemAttributes')

So if I send it the following UPC's
(644209004461, 009800895250, 024100440771) everything works fine and prodResult is set. But if I add 301357583001 to the list than the entire item_lookup fails and prodResult is never set. Is this expected? I would think it would return an error for that Item but return results for the rest. I can do the item_lookup's individually but that makes it way too slow when you have anything but a small number of items (sometimes I need to lookup a 15-20 items at a time).

Comments (18)

I quite agree with you. One bad itemId should not make the whole operation fail. The problem here, however, is that Amazon's XML response will contain an error message which this module picks up and throws the appropriate Python exception. It would be interesting to see if the rest of the XML contained item information.

Presumeably you are getting a amazonproduct.errors.InvalidParameterValue exception. If not please provide traceback and API version.

OK, thanks again Sebastian. I'm sure you realize it, but this issue is pretty important for performance reasons ... at roughly a second per Amazon call, doing individual lookups on 15-20 UPC's is too long for an end user to wait. I can prefetch some of it, but Amazon changes their offers pretty frequently so I can't cache offers for very long. I will take a look at the code as well, but will likely need a more experienced developer to figure it out.

Sebastian, so it turns out Amazon is returning valid results for all the other lookups like you suspected. I am working around this for now ... I simply modified the call function to not raise the InvalidParameter exception ... probably not a good long term solution :), but it works for my purposes for now ... perhaps longer term it could attach the error to the results and let the caller check for it and determine how to handle that Amazon error code based on the situation since Amazon seems to apply it very liberally. Hope that is helpful to you when you get around to this down the road. Thanks again for the great API!!