【发布时间】:2016-08-14 16:25:13
【问题描述】:
我有一个Python-eve公共API,我们可以顺便查询一下:
https://my-api.com/collections?where={"name":"peter"}
我想创建一个 API 网关来代理同一个 URL 端点,顺便说一句:
https://my-api-amazon-gateway.com/prod/collections?where={"name":"peter"}
我做了什么:
- 我创建了一个新的 API 网关,其中包含一个新的资源“集合”和该资源的“GET”方法。
- 在 collections - GET - Method Execution 中,在 Method Request 中:
- 在URL查询字符串参数中,我添加了一个名称为“where”的
- 在HTTP 请求标头中,我添加了一个名为“Content-Type”的标头
- 在“集合 - GET - 方法执行”中,在“集成请求”中
- 在 URL 查询字符串参数中我有名称“where”并映射自“method.request.querystring.where”
- 在 HTTP Headers 中,我添加了一项“Content-Type”,其映射来自“method.request.header.Content-Type”
如果我去方法测试,我把{"name":"peter"}作为查询字符串,application/json作为标题内容类型,一切都很好。
如果我部署 API 并在部署的 API 中尝试相同的端点,它就不起作用:
https://my-api-amazon-gateway.com/prod/collections?where={"name":"peter"}
它返回一个错误400 Bad Request。 CloudWatch 中没有记录任何内容。
如果我尝试击中
https://my-api-amazon-gateway.com/prod/collections?where=test
然后一切正常,我得到 HTTP 200 OK,出现 Python-eve 错误 The browser (or proxy) sent a request that this server could not understand.
这与如果我尝试点击
所以,由于我不知道的原因,测试有效,但是当查询字符串为对象时,部署的 API 网关无法正常工作。
有什么线索吗?
非常感谢!
【问题讨论】:
标签: api amazon-web-services aws-api-gateway eve