You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过AWS CLI更新API Gateway请求参数时遇BadRequestException报错求助

问题

尝试使用AWS CLI更新API Gateway的URI、connId和requestParameters等参数,调用PutIntegration操作时出现以下BadRequestException错误:

An error occurred (BadRequestException) when calling the PutIntegration operation: Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression specified: true, Invalid mapping expression specified: method.request.path.proxy

使用的命令如下:

aws apigateway put-integration \
--rest-api-id pk9ua4hlo9 \
--resource-id j9oi19 \
--integration-http-method 'ANY' \
--http-method 'ANY' \
--type HTTP_PROXY \
--connection-type VPC_LINK \
--connection-id l89vnu \
--uri 'https://aus.gov/mkt/{proxy}' \
--request-parameters "method.request.path.proxy=true"

移除request-parameters参数后命令可正常执行,请问该命令存在什么问题?

原因与解决方法

问题出在--request-parameters的参数格式上:

  • 对于HTTP_PROXY类型的集成,request-parameters的作用是映射请求参数,格式应为集成侧参数=方法侧参数,而非方法侧参数=true。
  • 要将API Gateway的路径参数method.request.path.proxy映射到集成URI中的{proxy},正确格式是integration.request.path.proxy=method.request.path.proxy。
  • 原命令里的method.request.path.proxy=true完全不符合参数映射规则,导致API Gateway解析时抛出无效表达式错误。

修正后的命令:

aws apigateway put-integration \
--rest-api-id pk9ua4hlo9 \
--resource-id j9oi19 \
--integration-http-method 'ANY' \
--http-method 'ANY' \
--type HTTP_PROXY \
--connection-type VPC_LINK \
--connection-id l89vnu \
--uri 'https://aus.gov/mkt/{proxy}' \
--request-parameters "integration.request.path.proxy=method.request.path.proxy"

内容的提问来源于stack exchange,提问作者placplacboom

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 07:42:36