Hi there
So I'm looking to get items back from the affiliate api (think its known as PA API), I can use the scratchpad under the affiliate part and it works ok. If I then take this code as cURL and import this into postman it only works once and then I get the following error returned:
{
"__type": "com.amazon.paapi5#InvalidSignatureException",
"Errors": [
{
"Code": "InvalidSignature",
"Message": "The request has not been correctly signed. If you are using an AWS SDK, requests are signed for you automatically; otherwise, go to https://webservices.amazon.co.uk/paapi5/documentation/sending-request.html#signing."
}
]
}
What I'm actually looking to do long term is take the code then from postman to use it in a C# application. Which would look something like this:
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://webservices.amazon.co.uk/paapi5/searchitems");
request.Headers.Add("Host", "webservices.amazon.co.uk");
request.Headers.Add("Accept", "application/json, text/javascript");
request.Headers.Add("Accept-Language", "en-US");
request.Headers.Add("X-Amz-Date", "20240308T155220Z");
request.Headers.Add("X-Amz-Target", "com.amazon.paapi5.v1.ProductAdvertisingAPIv1.SearchItems");
//request.Headers.Add("Content-Encoding", "amz-1.0");
request.Headers.Add("Authorization", "AWS4-HMAC-SHA256 Credential=###/20240308/eu-west-1/ProductAdvertisingAPI/aws4_request SignedHeaders=content-encoding;host;x-amz-date;x-amz-target Signature=873f938eec02d205297acc823b89fc1de334ee2fca3d3ba017b0c98394676781");
var content = new StringContent("{\n\"Keywords\": \"yoshi\",\n\"Resources\": [\n\"Images.Primary.Medium\",\n\"ItemInfo.Title\",\n\"Offers.Listings.Condition\",\n\"Offers.Listings.Price\"\n],\n\"ItemCount\": 1,\n\"PartnerTag\": \"###\",\n\"PartnerType\": \"Associates\",\n\"Marketplace\": \"www.amazon.co.uk\"\n}", null, "application/json; charset=UTF-8");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
return Json("none");
I seem to of hit a wall here with my understanding, guess I need to sign each request perhaps:
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-signing.html
I guess this has been before and there is code samples in C# as this would seem a very common thing to want to do, I've tried looking over the documentation (spent hours on this) I can't seem to get it work or even work out if what I'm doing is correct. Anyone out there done this before or can provide any insight?