Reputation: 531
How can I resolve the signature issue I'm facing when trying to access a feed document link from the Amazon SP API?
I have been utilizing the API mentioned below to create feed documents successfully:
API: https://sellingpartnerapi-na.amazon.com/feeds/2021-06-30/documents
However, when attempting to open the document link generated by the API, I am encountering a signature issue.
This is the Error I am getting
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
<AWSAccessKeyId>ID</AWSAccessKeyId>
<StringToSign>AWS4-HMAC-SHA256 20230808T124615Z 20230808/us-east-1/s3/aws4_request 61c729c2ca5fb09dd58a387ef1d3ace2133e80b84604aceebc7126e1f574adc9</StringToSign>
<SignatureProvided>60c4b5671d3a97f085e0e306a1458935b4b73e77e34d29184677424ed5bae5aa</SignatureProvided>
<StringToSignBytes>41 57 53 34 2d 48 4d 41 43 2d 53 48 41 32 35 36 0a 32 30 32 33 30 38 30 38 54 31 32 34 36 31 35 5a 0a 32 30 32 33 30 38 30 38 2f 75 73 2d 65 61 73 74 2d 31 2f 73 33 2f 61 77 73 34 5f 72 65 71 75 65 73 74 0a 36 31 63 37 32 39 63 32 63 61 35 66 62 30 39 64 64 35 38 61 33 38 37 65 66 31 64 33 61 63 65 32 31 33 33 65 38 30 62 38 34 36 30 34 61 63 65 65 62 63 37 31 32 36 65 31 66 35 37 34 61 64 63 39</StringToSignBytes>
<CanonicalRequest>GET //NinetyDays/amzn1.tortuga.4.na.15401127-ae1a-4f28-a919-591f7b836d65.T2CN4ZABFR7TJ7 X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA5U6MO6RANIQBJIW5%2F20230808%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230808T124615Z&X-Amz-Expires=300&X-Amz-SignedHeaders=content-type%3Bhost content-type: host:tortuga-prod-na.s3-external-1.amazonaws.com content-type;host UNSIGNED-PAYLOAD</CanonicalRequest>
<CanonicalRequestBytes>47 45 54 0a 2f 2f 4e 69 6e 65 74 79 44 61 79 73 2f 61 6d 7a 6e 31 2e 74 6f 72 74 75 67 61 2e 34 2e 6e 61 2e 31 35 34 30 31 31 32 37 2d 61 65 31 61 2d 34 66 32 38 2d 61 39 31 39 2d 35 39 31 66 37 62 38 33 36 64 36 35 2e 54 32 43 4e 34 5a 41 42 46 52 37 54 4a 37 0a 58 2d 41 6d 7a 2d 41 6c 67 6f 72 69 74 68 6d 3d 41 57 53 34 2d 48 4d 41 43 2d 53 48 41 32 35 36 26 58 2d 41 6d 7a 2d 43 72 65 64 65 6e 74 69 61 6c 3d 41 4b 49 41 35 55 36 4d 4f 36 52 41 4e 49 51 42 4a 49 57 35 25 32 46 32 30 32 33 30 38 30 38 25 32 46 75 73 2d 65 61 73 74 2d 31 25 32 46 73 33 25 32 46 61 77 73 34 5f 72 65 71 75 65 73 74 26 58 2d 41 6d 7a 2d 44 61 74 65 3d 32 30 32 33 30 38 30 38 54 31 32 34 36 31 35 5a 26 58 2d 41 6d 7a 2d 45 78 70 69 72 65 73 3d 33 30 30 26 58 2d 41 6d 7a 2d 53 69 67 6e 65 64 48 65 61 64 65 72 73 3d 63 6f 6e 74 65 6e 74 2d 74 79 70 65 25 33 42 68 6f 73 74 0a 63 6f 6e 74 65 6e 74 2d 74 79 70 65 3a 0a 68 6f 73 74 3a 74 6f 72 74 75 67 61 2d 70 72 6f 64 2d 6e 61 2e 73 33 2d 65 78 74 65 72 6e 61 6c 2d 31 2e 61 6d 61 7a 6f 6e 61 77 73 2e 63 6f 6d 0a 0a 63 6f 6e 74 65 6e 74 2d 74 79 70 65 3b 68 6f 73 74 0a 55 4e 53 49 47 4e 45 44 2d 50 41 59 4c 4f 41 44</CanonicalRequestBytes>
<RequestId>6ZT96W3BYGNWY38D</RequestId>
<HostId>F3JHNt5H3NanKm6rJOG1vbzRhSHuDeNpr4tLIPasUTr64KI6HvpUQdwErURNYRK4Z5wYyWif7io=</HostId>
</Error>
I am calling this API (https://sellingpartnerapi-na.amazon.com/feeds/2021-06-30/documents) with a POST request with "contentType":"text/xml; charset=utf-8" in the body with the token set in the header.
This is the Postmen collection (Amazon sp API collection)
you can find the API call in feeds documents API POST request.
Any guidance or expertise would be greatly appreciated.
Upvotes: 1
Views: 473
Reputation: 4046
I finally found what was the issue
key is to
Content-Type
header which has to be exactly the same for both requestsI will provide full example with JSON_LISTINGS_FEED
content
curl --location 'https://sellingpartnerapi-eu.amazon.com/feeds/2021-06-30/documents' \
--header 'Content-Type: application/json' \
--header 'x-amz-access-token: Atza|xxxxx' \
--data '{
"contentType":"application/json"
}'
response:
{
"feedDocumentId":"amzn1.tortuga.4.eu.AAAAAA",
"url": "https://tortuga-prod-eu.s3-eu-west-1.amazonaws.com/xxxxx.amzn1.tortuga.4.eu.TBQCUC81FDX8P?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20241015T192701Z&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Expires=300&X-Amz-Credential=xxxxxxxxxx"
}
curl --location --request PUT 'https://tortuga-prod-eu.s3-eu-west-1.amazonaws.com/xxxxx.amzn1.tortuga.4.eu.TBQCUC81FDX8P?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20241015T192701Z&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Expires=300&X-Amz-Credential=xxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"header": {
"sellerId": "A3XXXXXXXXXX",
"version": "2.0",
"issueLocale": "de_DE"
},
"messages": [
{
"messageId": 1,
"sku": "12345",
"operationType": "PARTIAL_UPDATE",
"productType": "PRODUCT",
"attributes": {
"fulfillment_availability": [
{
"fulfillment_channel_code": "DEFAULT",
"quantity": 1
}
]
}
},
]
}'
curl --location 'https://sellingpartnerapi-eu.amazon.com/feeds/2021-06-30/feeds' \
--header 'Content-Type: application/json' \
--header 'x-amz-access-token: Atza|xxxxx' \
--data '{
"inputFeedDocumentId": "amzn1.tortuga.4.eu.AAAAAA",
"feedType": "JSON_LISTINGS_FEED",
"marketplaceIds": [
"A1XXXXXXXXXXX"
],
"feedOptions": {}
}'
Upvotes: 1