C#Webclient发布到AWS API Gateway端点

时间:2018-07-09 21:30:31

标签: amazon-web-services aws-lambda aws-api-gateway aws-step-functions

我在尝试发布到API网关端点时遇到一些问题。

在我的API网关上,我已经设置了网关,并通过该工具进行了测试,并且正在获得结果,并且可以验证step函数实际上是否在适当地执行请求。

{
  "executionArn": "arn:aws:states:us-east-2:xxxxxxxxxxxx:execution:DevStateMachine-XXXXXXXXXXX:c9047982-e7f8-4b72-98d3-281db0eb4c30",
  "startDate": 1531170720.489
}

我已经为我的开发环境为此设置了一个舞台,在那里一切看起来也不错。在其中提供了要发布的网址。

https://xxxxxxxxxx.execute-api.us-east-2.amazonaws.com/dev/assignments

在我的C#代码中,我将Web客户端定义如下:

    public Guid QueueAssignment(AssignmentDTO assignment)
    {

        using (var client = new HttpClient())
        {

            var data = JsonConvert.SerializeObject(assignment);
            var content = new StringContent(data);
            var uri = "https://xxxxxxxxxx.execute-api.us-east-2.amazonaws.com/dev/assignments"
            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var response = client.PostAsync(uri, content).Result;
            if (response.IsSuccessStatusCode)
            {
                _logger.Info("Successfully posted to AWS Step Function");
                _logger.Info(response);
            }
            else
                _logger.Error("Error posting to AWS Step Function");
                _logger.Error(response);

        }
}

每次尝试发布此信息时,都会出现以下错误:

System.Net.WebException: The remote name could not be resolved: 'https://xxxxxxxxxx.execute-api.us-east-2.amazonaws.com'

在发布到此URI或我需要执行的某种类型的转换时,我是否缺少某些内容?我在哪里继续下去有点茫然。

0 个答案:

没有答案