7

Can somebody tell me C# excample of using Amazon Product Advertising API, for example to lookup item. All i found is not working now because of changes.

The most popular error is "Failed serialization of message body: ItemSearchRequest1 cant create temporary class"

starball
  • 20,030
  • 7
  • 43
  • 238
user1262425
  • 309
  • 2
  • 6
  • 17
  • Since they have the WSDL support, I would think you'd just have to add a reference to the web service in VS and be good to go, at least in terms of getting the call to go out. – James Manning May 06 '12 at 23:39

3 Answers3

9

You can use the following nuget package.

PM> Install-Package Nager.AmazonProductAdvertising

Search example

var authentication = new AmazonAuthentication();
authentication.AccessKey = "accesskey";
authentication.SecretKey = "secretkey";

var client = new AmazonProductAdvertisingClient(authentication, AmazonEndpoint.DE);
var result = await client.SearchItemsAsync("canon eos");
live2
  • 3,771
  • 2
  • 37
  • 46
  • 1
    Thanks, I hope it will not use your associate id and access key :) – King_Fisher Sep 10 '17 at 07:27
  • The code is open source you can build your own binary https://github.com/tinohager/Nager.AmazonProductAdvertising – live2 Sep 10 '17 at 14:59
  • Nager.AmazonProductAdvertising -Not able to build. its keep throwing some errors on xml attributes(assembly reference missing eventhough Sytesm.Xml referenced), Any Idea ? – King_Fisher Sep 12 '17 at 20:05
  • I think here is the wrong place, if you have a problem create a issue – live2 Sep 12 '17 at 20:23
  • I meant the source code you referred github.com/tinohager/Nager.AmazonProductAdvertising. Can you able to build the source code in gitgub ? – King_Fisher Sep 12 '17 at 20:41
4

There's a C# sample here:

http://aws.amazon.com/code/Product-Advertising-API/3941

FWIW, the AWS thread I mentioned includes these steps for a workaround:

These are the steps as of January 31, 2012 to fix this issue in Visual Studio for .Net clients:

1) Click the "Show all files" button in the Solution Explorer for the project containing the amazon service reference.

2) Expand the reference and open the AWSECommerceService.wsdl file in the editor

3) On line 584 change the "maxOccurs' to "1".

<xs:element minOccurs="0" maxOccurs="1" name="ImageSets">

4) Save the AWSECommerceService.wsdl file

5) Right click Reference.svcmap and click "Run custom tool"

6) Expand Reference.svcmap and open either Reference.cs or Reference.vb

James Manning
  • 13,429
  • 2
  • 40
  • 64
2

If you want to use Html REST instead of Soap/Wsdl, I put an example updated for the 2011 API and Visual Studio 2012 on my blog: "Up to date CSharp REST sample"

BernardG
  • 1,956
  • 3
  • 17
  • 25