[英]Angular $resource POST request query params not detected by AWS API Gateway?
I'm testing out AWS's API Gateway and I can't get it to read a query string parameter included in POST requests from Angular. 我正在测试AWS的API网关,但无法读取来自Angular的POST请求中包含的查询字符串参数。
However, AWS's API Gateway DOES detect the query string param when I use cURL, so this must be an Angular issue. 但是,当我使用cURL时,AWS的API网关确实会检测查询字符串参数,因此这一定是一个Angular问题。 Am I missing a Header or something?
我是否缺少标题或其他内容?
FYI, I have set up template mapping correctly on the API Gateway, so that is not the issue. 仅供参考,我已经在API网关上正确设置了模板映射,所以这不是问题。
https://cabvt12afasf4.execute-api.us-east-1.amazonaws.com/resource?access_token=1234112313123
resourceCreate: {
method: 'POST',
isArray: false,
params: {
access_token: access_token
},
url: 'https://cabvtj3br4.execute-api.us-east-1.amazonaws.com/resource'
},
The problem was this: 问题是这样的:
Angular sets the Content-Type header to application/json;charset=UTF-8
and this was breaking the AWS API Gateway. Angular将Content-Type标头设置为
application/json;charset=UTF-8
,这破坏了AWS API Gateway。
Switching Content-Type to application/json
in my Angular $resource solved the problem. 在我的Angular $ resource中将Content-Type切换为
application/json
解决此问题。
createResource: {
method: 'POST',
isArray: false,
headers: {
'Content-Type': 'application/json'
},
url: 'http://www.resource.com/create'
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.