2

I'm trying to retrieve data from 'Amazon Product Advertising API', and I see that I need to sign my request, and then the response is an XML document which should be parsed.

I wonder if there is any library which I can send my requests throught, and recieve the response back as an object.

If not, what should I do to convert those XML reponses to an object ? I've read about schemas, but where do I get those schemas from and where do I get from the defention for the response objects so I could define them my self.

Thanks alot!

user3125999
  • 201
  • 4
  • 14
  • AWS has an C# SDK that handles signing requests and parsing responses. Have you looked into that? I haven't used product advertising but I'm sure it covers that API too – Volkan Paksoy Nov 07 '15 at 12:32
  • IMHO, XML DOM is an object. Re-consider why you need the response in a POCO, you might find that the conversion to an intermediate object is just overhead. You're likely a) inserting into a DB, b) presenting to HTML. Both can be done easily with the data remaining in the XML, and not a POCO. – William Walseth Nov 07 '15 at 15:55

2 Answers2

5

You can use the following nuget package

PM> Install-Package Nager.AmazonProductAdvertising

Example:

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

var client = new AmazonProductAdvertisingClient(authentication, AmazonEndpoint.DE);
//Search
var result = await client.SearchItemsAsync("canon eos");
//Lookup
var result = await client.GetItemsAsync("B00BYPW00I");
live2
  • 3,771
  • 2
  • 37
  • 46
  • Hi, when I try to run above code, result always return null. I don't think that I have a problem with AccessKey and SecretKey but I cannot find what is the problem. Do you have any suggestion? – Gurcan Jan 02 '18 at 12:15
  • 1
    check the response of this event `wrapper.ErrorReceived += (errorResonse) => { System.Diagnostics.Debug.WriteLine(errorResonse.Error.Message); };` – live2 Jan 02 '18 at 12:44
  • Many thanks for your reply. I've implemented the event but no error has returned. Is there anything I can check? – Gurcan Jan 03 '18 at 08:06
  • Please open a new question and post your code example – live2 Jan 03 '18 at 08:40
  • This is a useful post and I found that the nuget is being updated regularly – Balaji Birajdar Dec 02 '19 at 09:16
0

There is a library that helps you sign requests AND process the responses by converting the XML into a relatively easy-to-use object. I've been using it for a few weeks now and wrote my own helper classes to really make querying the API fast and easy.

I wrote a demo console C# app where you can just plug in your Amazon credentials and start playing around here: https://github.com/zoenberger/AmazonProductAdvertising

I also answered a similar question here: https://stackoverflow.com/a/33617604/5543992

Community
  • 1
  • 1
Jeffrey
  • 143
  • 2
  • 10