繁体   English   中英

AWS API Gateway未检测到角$ resource POST请求查询参数?

[英]Angular $resource POST request query params not detected by AWS API Gateway?

我正在测试AWS的API网关,但无法读取来自Angular的POST请求中包含的查询字符串参数。

但是,当我使用cURL时,AWS的API网关确实会检测查询字符串参数,因此这一定是一个Angular问题。 我是否缺少标题或其他内容?

仅供参考,我已经在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'
    },

问题是这样的:

Angular将Content-Type标头设置为application/json;charset=UTF-8 ,这破坏了AWS API Gateway。

在我的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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM