Ada*_*ant 6 amazon-web-services aws-api-gateway aws-codebuild api-gateway
目前还没有专门集成 API 网关和 Codebuild 的实际指南,因此我正在研究几个并尝试适应。
我已根据本文档设置了我的角色和策略,并且已成功设置并运行了我的 CodeBuild 项目。
我已经设置了一个 POST 端点,参考CodeBuild API 文档中的操作:
我正在使用端点的测试选项卡来发送
{ "project": "my-project" }
但我得到了这个回应
{
"Output": {
"__type": "com.amazon.coral.service#UnknownOperationException",
"message": null
},
"Version": "1.0"
}
Run Code Online (Sandbox Code Playgroud)
日志
Execution log for request b0ee0d54-c1d0-11e9-9ff3-e9448aaf711c
Sun Aug 18 15:56:07 UTC 2019 : Starting execution for request: b0ee0d54-c1d0-11e9-9ff3-e9448aaf711c
Sun Aug 18 15:56:07 UTC 2019 : HTTP Method: POST, Resource Path: /vegankit/stage
Sun Aug 18 15:56:07 UTC 2019 : Method request path: {}
Sun Aug 18 15:56:07 UTC 2019 : Method request query string: {}
Sun Aug 18 15:56:07 UTC 2019 : Method request headers: {}
Sun Aug 18 15:56:07 UTC 2019 : Method request body before transformations: { "project": "stage-vegankit-com" }
Sun Aug 18 15:56:07 UTC 2019 : Endpoint request URI: https://codebuild.us-east-1.amazonaws.com/?Action=StartBuild
Sun Aug 18 15:56:07 UTC 2019 : Endpoint request headers: {Authorization=****************************************************************************************************************************************************************************************************************************************************************************388440, X-Amz-Date=20190818T155607Z, x-amzn-apigateway-api-id=[redacted], Accept=application/json, User-Agent=AmazonAPIGateway_[redacted], X-Amz-Security-Token=[redacted] [TRUNCATED]
Sun Aug 18 15:56:07 UTC 2019 : Endpoint request body after transformations: { "project": "my-project" }
Sun Aug 18 15:56:07 UTC 2019 : Sending request to https://codebuild.us-east-1.amazonaws.com/?Action=StartBuild
Sun Aug 18 15:56:08 UTC 2019 : Received response. Status: 200, Integration latency: 360 ms
Sun Aug 18 15:56:08 UTC 2019 : Endpoint response headers: {x-amzn-RequestId=7afcfc90-de3e-424a-b7d9-b47ff926c1d0, Content-Type=application/json, Content-Length=105, Date=Sun, 18 Aug 2019 15:56:08 GMT}
Sun Aug 18 15:56:08 UTC 2019 : Endpoint response body before transformations: {"Output":{"__type":"com.amazon.coral.service#UnknownOperationException","message":null},"Version":"1.0"}
Sun Aug 18 15:56:08 UTC 2019 : Method response body after transformations: {"Output":{"__type":"com.amazon.coral.service#UnknownOperationException","message":null},"Version":"1.0"}
Sun Aug 18 15:56:08 UTC 2019 : Method response headers: {X-Amzn-Trace-Id=Root=[redacted], Content-Type=application/json}
Sun Aug 18 15:56:08 UTC 2019 : Successfully completed execution
Sun Aug 18 15:56:08 UTC 2019 : Method completed with status: 200
Run Code Online (Sandbox Code Playgroud)
小智 14
在 HTTP headers 中,您应该定义这两个标头:
Content-Type = 'application/x-amz-json-1.1'
X-Amz-Target = 'CodeBuild_20161006.StartBuild'
Run Code Online (Sandbox Code Playgroud)
起初我只添加了 X-Amz-Target 但我继续收到相同的错误,后来我在 github 问题中发现有人还将具有该值的 Content-Type 传递给请求,我尝试并工作了。
我希望这对将来的其他人有帮助。
| 归档时间: |
|
| 查看次数: |
19590 次 |
| 最近记录: |