0
votes

I am trying to write a POST request to fetch a message from my SQS server in C++ using V4 signing, The POST message looks like this,

POST /134148934511/Localhost/?Action=ReceiveMessage&SignatureMethod=AWS4-HMAC-SHA256&SignatureVersion=4&Version=2012-11-05&X-Amz-Credential=AKIAI21OTNJCTG12UP7NA/20140602/us-east-1/sqs/aws4_request&X-Amz-Date=20140602T152045Z&X-Amz-Content-Sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855&X-Amz-SignedHeaders=host;x-amz-content-sha256;x-amz-date&Signature=6fada82dcfa52392bd15d29946115e34e1f2485fe87a59cead8320fa05bcea67 HTTP/1.1 Host: sqs.us-east-1.amazonaws.com Accept: / Content-Length: 0 Content-Type: application/x-www-form-urlencoded

But I am receiving a 403 Forbidden error message (though I have the required permissions). (I am sure that the aws version 4 signing process is correct(checked with S3)) What I am doing wrong ?

1

1 Answers

1
votes

Answering my own question.

There are few things wrong in the above request.

a) In a POST request, you do not include the query arguments with the URL, instead you add it to the body itself (This is also indicated to the server using header "Content-Type: application/x-www-form-urlencoded").

b) Always remember to add all the headers to the curl request which you used while creating the signature, else it will throw a "signature does not match" error.