1

I have a AWS API Gateway connected to SQS queue and I can post messages through the console and Postman using the AWS signature.

I need to implement the POST request in a .Net app and although I get an Ok response, the message posted is not sended to the queue. This is my code:

            var signer = new AWS4RequestSigner(AccessKey, SecretKey);
            var request = new HttpRequestMessage
            {
                Method = HttpMethod.Post,
                RequestUri = new Uri(uri)
            };

            var parameters = new List<KeyValuePair<string, string>>();
            parameters.Add(new KeyValuePair<string, string>("Client", client));
            parameters.Add(new KeyValuePair<string, string>("Study", study));

            request.Content = new FormUrlEncodedContent(parameters);

            request = await signer.Sign(request, "execute-api", "eu-west-1");

            var client = new HttpClient();
            var response = await client.SendAsync(request);

            return response.IsSuccessStatusCode;

Without the signer I also get HTTP 200 but this is another "mistery".

JourneyToJsDude
  • 101
  • 1
  • 9

1 Answers1

1

Finally I solved this issue after reading this answer: How to send a Post body in the HttpClient request in Windows Phone 8?

Instead of the content sent as FormUrlEncodedContent, just send it as StringContent.

JourneyToJsDude
  • 101
  • 1
  • 9