AWS API Gateway - Call GET Method with C# SDK

Viewed 809

I have an API Gateway that uses IAM authorization. I have a C# application that I'm hoping to call the API with. I started with a GetMethodRequest but I don't see anyway to set the PathPart parameter.

var userId = _remoteCredentials.UserId;
var key = _remoteCredentials.Key;

var client = new AmazonAPIGatewayClient(userId, key, Amazon.RegionEndpoint.USEast2);
GetMethodRequest getMethodRequest = new GetMethodRequest();
getMethodRequest.HttpMethod = HttpMethod.Get.ToString();
getMethodRequest.ResourceId = "4abcde";
getMethodRequest.RestApiId = "aasfasdfs";

var task = Task.Run(async () => await client.GetMethodAsync(getMethodRequest).ConfigureAwait(false));

I was expecting something like the Test-AGInvokeMethod in the Powershell SDK which allows me to set the query string and the path.

$response = Test-AGInvokeMethod 
                   -RestApiId aasfasdfs
                   -ResourceId 4abcde
                   -HttpMethod GET 
                   -PathWithQueryString '/etl/upload_url'

Any help is greatly appreciated.

EDIT Below is something of a solution that I ended up using the AWS4RequestSigner is a library that I found on Github

var signer = new AWS4RequestSigner(userId, key);
var destinationUrl = string.Format("https://ad9vxabc123.execute-api.us-east-2.amazonaws.com/dev/etl/summary/latest?tms_id={0}&model_id={1}", _tmsId, _modelId);
var request = new HttpRequestMessage
{
    Method = HttpMethod.Get,
    RequestUri = new Uri(destinationUrl),
};

var signed = Task.Run(async () => await signer.Sign(request, "execute-api", "us-east-2").ConfigureAwait(false));
var signedResult = signed.Result;
1 Answers
Related