AWS API Gateway,HTTP端点路径参数

时间:2018-12-15 00:26:29

标签: amazon-web-services aws-api-gateway

我正在尝试配置API网关以将请求路由到我们的后端服务。目前,它实际上是在进行一对一映射。问题是我无法获取路径参数。我有一个资源,其路径设置为{userId},并且该资源上的方法设置为与端点http://${stageVariables.service}/users/{userId}的HTTP集成。在测试端点时,我在日志中看到以下内容:

Execution log for request f750dacf-fffd-11e8-b009-d7aaa40efb2f
Sat Dec 15 00:11:27 UTC 2018 : Starting execution for request: f750dacf-fffd-11e8-b009-d7aaa40efb2f
Sat Dec 15 00:11:27 UTC 2018 : HTTP Method: GET, Resource Path: /briefbuilder/users/4
Sat Dec 15 00:11:27 UTC 2018 : Method request path: {userId=4}
Sat Dec 15 00:11:27 UTC 2018 : Method request query string: {}
Sat Dec 15 00:11:27 UTC 2018 : Method request headers: {}
Sat Dec 15 00:11:27 UTC 2018 : Method request body before transformations: 
Sat Dec 15 00:11:27 UTC 2018 : Endpoint request URI: http://[redacted].us-east-1.elasticbeanstalk.com/users/{userId}
Sat Dec 15 00:11:27 UTC 2018 : Endpoint request headers: {x-amzn-apigateway-api-id=[redacted], Accept=application/json, User-Agent=AmazonAPIGateway_[redacted], X-Amzn-Trace-Id=Root=[redacted]}
Sat Dec 15 00:11:27 UTC 2018 : Endpoint request body after transformations: 
Sat Dec 15 00:11:27 UTC 2018 : Sending request to http://[redacted].us-east-1.elasticbeanstalk.com/users/{userId}
Sat Dec 15 00:11:27 UTC 2018 : Execution failed due to configuration error: Illegal character in path at index 67: http://[redacted].us-east-1.elasticbeanstalk.com/users/{userId}
Sat Dec 15 00:11:27 UTC 2018 : Method completed with status: 500

奇怪的是,它正在扩展stage变量,而不是path参数。如果我从端点字段中删除{userId},则会收到一条警告,提示您并非所有路径参数都在使用中,因此似乎应该正确设置其格式。

0 个答案:

没有答案