Amazon (AWS) - The request must contain the parameter Signature
Asked Answered
C

2

7

I'm struggling with the final part of getting my first bit of code working with the AWS - I have got this far, I attached the web reference in VS and this have this

amazon.AWSECommerceService service = new amazon.AWSECommerceService();

// prepare an ItemSearch request
amazon.ItemSearchRequest request = new amazon.ItemSearchRequest();
request.SearchIndex = "DVD";
request.Title = "scream";
request.ResponseGroup = new string[] { "Small" };

amazon.ItemSearch itemSearch = new amazon.ItemSearch();
itemSearch.AssociateTag = "";
itemSearch.Request = new ItemSearchRequest[] { request };
itemSearch.AWSAccessKeyId = ConfigurationManager.AppSettings["AwsAccessKeyId"];

itemSearch.Request = new ItemSearchRequest[] { request };
ItemSearchResponse response = service.ItemSearch(itemSearch);

// write out the results
foreach (var item in response.Items[0].Item)
{
    Response.Write(item.ItemAttributes.Title + "<br>");
}

I get the error

The request must contain the parameter Signature.

I know you have to 'sign' requests now, but can't figure out 'where' I would do this or how? any help greatly appreciated?

Chastity answered 29/5, 2010 at 13:4 Comment(1)
leen3o did your code run ? i have same issue. can u help me ??Picrite
R
2

You have to add to the SOAP request headers including your Amazon access key ID, a timestamp, and the SHA256 hash of the request operation and the timestamp. To accomplish that, you would need access to the SOAP message just before it is going to be sent out. There's a walkthrough and a sample project I put together at http://flyingpies.wordpress.com/2009/08/01/17/.

Responsible answered 29/5, 2010 at 18:58 Comment(1)
Hi - I followed your tutorial before I posted this, but could not get it to work in my web application. Every time it just could not understand what AWSECommerceServicePortTypeClient was? I managed to get some sample code working from Amazon in the end - But I had to install Microsoft WSE 3.0 and remove my web reference :S Bloody crazy amount of work to get something to simple working!!!Chastity
H
1

For the record:

Another reason to get this error is due to keywords with spaces in it.

Example:

'http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=xxx&AssociateTag=usernetmax-20&Version=2011-08-01&Operation=ItemSearch&ResponseGroup=Medium,Offers&SearchIndex=All&Keywords=Baby Stroller&MerchantId=All&Condition=All&Availability=Available&ItemPage=1&Timestamp=2012-05-16T02:17:32Z&Signature=ye5c2jo99cr3%2BPXVkMyXX8vMhTC21UO4XfHpA21%2BUCs%3D'

It should be:

'http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=xxx&AssociateTag=usernetmax-20&Version=2011-08-01&Operation=ItemSearch&ResponseGroup=Medium,Offers&SearchIndex=All&Keywords=Baby%20Stroller&MerchantId=All&Condition=All&Availability=Available&ItemPage=1&Timestamp=2012-05-16T02:17:32Z&Signature=ye5c2jo99cr3%2BPXVkMyXX8vMhTC21UO4XfHpA21%2BUCs%3D'

PHP solution:

$Keywords = str_replace(' ', '%20', $Keywords);

or

$Keywords = urlencode($Keywords);
Hofmannsthal answered 16/5, 2012 at 2:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.