because Amazon only sells new items. If you submitted a request without specifying a value for Condition
and received no results, you might assume that there are no items that satisfy the request. By setting
Condition to "All," however, you might find that items do satisfy the request.
A similar error message is displayed when, for example, you use
ItemLookup
to find an item that does
not exist in the Amazon catalog.
<Errors>
<Error>
<Code>AWS.InvalidParameterValue</Code>
<Message>B0111NOSUCHITEM is not a valid value for ItemId. Please change
this value and retry your request.
</Message>
</Error>
</Errors>
ItemId was set equal to "B0111NoSuchItem" in the request. The error message shows that Product
Advertising API converts ItemId values to all caps.
Results and Errors
As long as the request is valid, Product Advertising API will try to process it. There are times when Product
Advertising API returns a result and an error. For example, if you had a batch request, one item might be
found, the other not. In that case,
IsValid
would be true, the response would contain the item attributes
of the item found, and the response would also contain an error message that the second item could not
be found. Product Advertising API attempts to return as much information as possible even when an error
prevents the successful completion of a portion of a request.
Retrieving Errors
Typically, you want your application to check whether or not a request generated an error before spending
any time processing results. The easiest way to find out if an error occurred is to look for an
Error
node
in the response.
XPath syntax provides a simple way to search for the presence of an
Error
node, as well as an easy
way to retrieve the error code and message. The following code snippet uses Perl and the XML::XPath
module to determine if an error occurred during a request. If an error occurred, the code prints the first
error code and message in the response.
use XML::XPath;
my $xp = XML::XPath->new(xml =>$response);
if ( $xp->find("//Error") )
{print "There was an error processing your request:\n", " Error code: ",
$xp->findvalue("//Error[1]/Code"), "\n", " ",
$xp->findvalue("//Error[1]/Message"), "\n\n"; }
Troubleshooting Applications
We recommend the following processes to diagnose and resolve problems with your Product Advertising
API-enabled Web sites or applications.
• Verify that Product Advertising API is running correctly.
To do this, simply open a browser window and submit a REST request. This will confirm that the service
is available and responding to requests. Normally Product Advertising API is available 24 hours per
day, 7 days per week.
API Version 2011-08-01
151
Product Advertising API Developer Guide
Retrieving Errors