Amazon APi网关无法生成转换后的请求 [英] Amazon APi gateway fails to generate transformed request
问题描述
我正在尝试将Amazon API网关与Lambda函数集成在一起.虽然我可以成功实现,但是当我尝试使用curl时失败了.
I was trying the integration of Amazon API gateway with Lambda function. I was successfully able to achieve though but when I tried with curl it fails.
Lambda方法,API网关集成以及集成请求下的模板映射已设置.
Lambda method, API gateway integration along with template mapping under integration request are setup.
当我从控制台运行测试"时,它工作正常
When I run "test" from console, it works fine
Execution log for request test-request
Wed Nov 04 07:27:30 UTC 2015 : Starting execution for request: test-invoke-request
Wed Nov 04 07:27:30 UTC 2015 : API Key: test-invoke-api-key
Wed Nov 04 07:27:30 UTC 2015 : Method request path: {service=xml}
Wed Nov 04 07:27:30 UTC 2015 : Method request query string: {}
Wed Nov 04 07:27:30 UTC 2015 : Method request headers: {}
Wed Nov 04 07:27:30 UTC 2015 : Method request body before transformations: Articletext
Wed Nov 04 07:27:30 UTC 2015 : Endpoint request body after transformations: {
"prog" : "xml",
"content" : "Articletext",
"test" : "{path={service=xml}, querystring={}, header={}}"
}
但是当我尝试通过curl访问它时,它在转换后无法创建适当的主体
but when I tries to access it through curl it is not able to create proper body after transformation
卷曲-X POST https://aaaaaaa.execute-api.us-west -2.amazonaws.com/beta/apitest/xml -H内容类型:application/x-www-form-urlencoded; charset = UTF-8"-数据二进制"Articletext"
curl -X POST https://aaaaaaa.execute-api.us-west-2.amazonaws.com/beta/apitest/xml -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" --data-binary "Articletext"
Starting execution for request:
Method request path: {service=xml}
Method request query string:
{}
Method request body before transformations: Articletext
Endpoint request body after transformations: Articletext
Endpoint response body before transformations:
{
"Type": "User",
"message": "Could not parse request body into json."
}
有人建议我缺零件吗?
推荐答案
请确保您的内容类型是您在集成请求模板中定义的内容.
Please make sure your content-type what you defined in integration request template.
您可以尝试使用curl命令.
You can try this curl command.
curl -X POST https://aaaaaaa .execute-api.us-west-2.amazonaws.com/beta/apitest/xml -H"Content-Type:application/json" --data-binary"Articletext"
curl -X POST https://aaaaaaa.execute-api.us-west-2.amazonaws.com/beta/apitest/xml -H "Content-Type: application/json" --data-binary "Articletext"
这篇关于Amazon APi网关无法生成转换后的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!