【发布时间】:2020-03-24 05:29:26
【问题描述】:
当使用Content-Type: application/x-www-form-urlencoded 和正文中的其他参数发出POST 请求时,许多服务可以接受URL 中的查询字符串参数,但AWS API Gateway 似乎不能同时接受查询字符串参数。
当我使用 application/x-www-form-urlencoded 的 POST 映射模板和查询字符串 URL 参数(使用 Lambda 函数)调用 AWS API Gateway 时,我收到以下错误:
{
"message":"When Content-Type:application/x-www-form-urlencoded,
URL cannot include query-string parameters (after '?'):
'/prod/webhook?inputType=wootric&outputType=glip&url=...'"
}
这是一个 cURL 示例:
curl -XPOST 'https://{myid}.execute-api.{myregion}.amazonaws.com/prod/webhook? \
inputType=wootric&outputType=glip&url=https://hooks.glip.com/webhook/ \
11112222-3333-4444-5555-666677778888' \
-d "@docs/handlers/wootric/event-example_response-created.txt" \
-H 'Content-Type: application/x-www-form-urlencoded' -v
具体目标是使用带有查询字符串参数的 URL 将 Wootric webhook 事件发布到 Lambda 函数。
您可以在这里获取代码:
https://github.com/grokify/chathooks
Wootric 事件正文文件在这里:
GitHub 问题在这里:
https://github.com/grokify/chathooks/issues/15
错误信息似乎很明确,但我想问一下:
- 是否有解决方法来配置 API 网关以支持两者?
- AWS 不支持这一点是否有基于标准的原因,或者这只是一个设计决策/限制?
如果没有解决方案,除了部署像 Heroku 这样的托管服务器解决方案之外,还有没有好的轻量级解决方案。此外,其他云服务是否通过其 API 网关 + 云功能支持此功能,例如 Google?
一些显示支持两者的示例:
【问题讨论】:
-
您是否以某种方式解决了这个问题?
标签: amazon-web-services aws-api-gateway query-string x-www-form-urlencoded