Question

I want to search for a product using the Amazon Product Advertising API.

I have started taking the Java example code to do a search for a product (com.advertising.api.sample).

Compiles and runs fine, but gives a Null Pointer Exception as the parsing of the response assumes everything will work OK (that's OK for a sample).

So, I do the same query using 'curl'....

curl http://ecs.amazonaws.com/onca/xml?AWSAccessKeyId=&ItemId=0545010225&Operation=ItemLookup&ResponseGroup=Small&Service=AWSECommerceService&Timestamp=2012-08-30T11%3A31%3A54Z&Version=2009-03-31&Signature=

which shows this output:

[1] 17603 [2] 17604 [3] 17605 [4] 17606 [5] 17607 [6] 17608 [7] 17609 [2] Done ItemId=0545010225 [3] Done Operation=ItemLookup [4] Done ResponseGroup=Small [5] Done Service=AWSECommerceService [6] Done Timestamp=2012-08-30T11%3A31%3A54Z [7] Done Version=2009-03-31

and the XML returns describes the error:

AWS.MissingServiceParameterYour request is missing the Service parameter. Please add the Service parameter

But, as you can see from the curl command input and it's logging, the service parameter is present and set to: AWSECommerceService as specified by the API

I realize I maybe doing something wrong, but it doesn't seem to be the Service parameter, and it's going to be tough to find the source of another problem with that error response.

Any ideas?

Was it helpful?

Solution

Interestingly, if I do the same request from browser, I get a different response: (abbreviated)

Your request is missing required parameters. Required parameters include AssociateTag.

So, you need to modify the Java REST Example code to include the mandatory "AssociateTag" parameter in the request. I did this modifying the SignedRequestHelper class.

Then it works, and you get the response expected.

OTHER TIPS

I found the problem was that the associateTag is required. I added the associateTag and the sample code worked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top