如何在API网关中设置带路径参数的端点URL?

时间:2017-09-09 01:41:11

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

我尝试在现有设置前设置API网关。每当我尝试使用参数添加端点时,我都会收到错误。

Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression parameter specified: method.request.querystring.type]

以下是截图:

enter image description here

enter image description here

我做错了什么?

2 个答案:

答案 0 :(得分:5)

我也有同样的问题。 这是你需要做的:

BTW:/number 不是此示例的一部分

  1. 创建新的API资源。
  2. 转到Method Request页面上的Method Execution
  3. enter image description here

    1. URL Query String Parameters下添加你的参数。您也可以将一些参数设置为Required
    2. enter image description here

      1. 返回Method Execution屏幕(见图1),然后点击Integration Request

      2. 现在,您可以在网址Query String Parameters下查看/设置(在我的情况下,它是自动创建的)params。如果没有,您可以如图所示定义它们。

      3. 完成所有操作后,点击ActionsDeploy API。 您可以在左侧菜单的Invoke URL标签下找到Stages

      4. enter image description here

        有关详细信息,您可以查看this page(AWS文档),它对此过程有很好的解释。 希望它有帮助:)

答案 1 :(得分:1)

http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-mappings.html

上述链接的第2步有明确的创建查询字符串映射和路径映射的过程。

根据您提供的屏幕截图,看起来方法执行时缺少映射变量。

希望它有所帮助。