SignatureDoesNotMatch error facing when tring to upload xml document amazon sp APIs for Feed 2021-06-30

68 Views Asked by At

I am tring to upload a xml file for inventory update but facing below error

  • SignatureDoesNotMatch
  • The request signature we calculated does not match the signature you provided. Check your key and signing method.

xml file is looking like below

<?xml version="1.0" encoding="iso-8859-1"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
    <Header>
        <DocumentVersion>1.01</DocumentVersion>
        <MerchantIdentifier>A2-----cxxxx---3Y4N7</MerchantIdentifier>
    </Header>
    <MessageType>Inventory</MessageType>
    <Message>
        <MessageID>1</MessageID>
        <OperationType>Update</OperationType>
        <Inventory>
            <SKU>853--xxxx-43</SKU>
            <Quantity>67</Quantity>
        </Inventory>
    </Message>
</AmazonEnvelope>

Full error message

<?xml version="1.0" encoding="UTF-8"?>
<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>AKIA5U6MO6RAHR6VGCOG</AWSAccessKeyId>
    <StringToSign>AWS4-HMAC-SHA256
20231127T165015Z
20231127/us-east-1/s3/aws4_request
42f52c78f36e0d1892784a6c2290cfbe0e3a387485f937487a3cdc8a2436e548</StringToSign>
    <SignatureProvided>62073c867470a03105029ae379f9e8ce89bd2b99a85779128f626905655c109d</SignatureProvided>
    <StringToSignBytes>41 57 53 34 2d 48 4d 41 43 2d 53 48 41 32 35 36 0a 32 30 32 33 31 31 32 37 54 31 36 35 30 31 35 5a 0a 32 30 32 33 31 31 32 37 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 34 32 66 35 32 63 37 38 66 33 36 65 30 64 31 38 39 32 37 38 34 61 36 63 32 32 39 30 63 66 62 65 30 65 33 61 33 38 37 34 38 35 66 39 33 37 34 38 37 61 33 63 64 63 38 61 32 34 33 36 65 35 34 38</StringToSignBytes>
    <CanonicalRequest>POST
/1ed2cca7-94cd-46d8-a2c1-6c312c8b6f3e.amzn1.tortuga.4.na.TVSQ1MGNZ1FDM
X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Credential=AKIA5U6MO6RAHR6VGCOG%2F20231127%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Date=20231127T165015Z&amp;X-Amz-Expires=300&amp;X-Amz-SignedHeaders=content-type%3Bhost
content-type:text/xml; charset=UTF-8
host:tortuga-prod-na.s3-external-1.amazonaws.com

content-type;host
UNSIGNED-PAYLOAD</CanonicalRequest>
    <CanonicalRequestBytes>50 4f 53 54 0a 2f 31 65 64 32 63 63 61 37 2d 39 34 63 64 2d 34 36 64 38 2d 61 32 63 31 2d 36 63 33 31 32 63 38 62 36 66 33 65 2e 61 6d 7a 6e 31 2e 74 6f 72 74 75 67 61 2e 34 2e 6e 61 2e 54 56 53 51 31 4d 47 4e 5a 31 46 44 4d 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 48 52 36 56 47 43 4f 47 25 32 46 32 30 32 33 31 31 32 37 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 31 31 32 37 54 31 36 35 30 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 74 65 78 74 2f 78 6d 6c 3b 20 63 68 61 72 73 65 74 3d 55 54 46 2d 38 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>C2QR1MQNBD3TE9YX</RequestId>
    <HostId>tFy9xBzUcU0QXiujW1/GgMZEuXlWqZFLuNLBmn/r2HtEF/FIcfEutv9Td0D1UHWCf5PNIcAEm4k=</HostId>
</Error>
1

There are 1 best solutions below

0
On

I was working on the same last day and came across same issue. I had to make sure I'm passing the content type in header while uploading the document and the content type passed while creating the document feed on step before that are same (i.e. while creating feed which returns document id and URL).

As far as I know the host in the request header too match, but in my case the same server made the call for create feed and upload document feed. So I had not passed host in header explicitly and it worked. If you are using two different servers to make these calls, Try passing a unique host name explicitly in header.

Cheers Ritz