本文介绍了接口网关触发CodeBuild时的com.amazon.coral.service#UnknownOperationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有专门集成API网关和代码构建的实际指南,所以我正在研究几个,并试图适应它们。

我已根据this documentation设置了我的角色和策略,并且我的CodeBuild项目已成功安装并运行。

我已经这样设置了一个POST端点,参考actions from the CodeBuild API documentation

并且我正在使用端点的"测试"选项卡来发送

{ "project": "my-project" }

但我收到此回复

{
  "Output": {
    "__type": "com.amazon.coral.service#UnknownOperationException",
    "message": null
  },
  "Version": "1.0"
}

日志

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

推荐答案

在HTTP头中,您应该定义这两个头:

Content-Type = 'application/x-amz-json-1.1'
X-Amz-Target = 'CodeBuild_20161006.StartBuild'

起初我只添加了X-AMZ-Target,但我继续收到相同的错误,后来在GitHub问题中我发现有人还在向请求传递带有该值的Content-Type,我尝试并工作了。

我希望这能在将来帮助其他人。

这篇关于接口网关触发CodeBuild时的com.amazon.coral.service#UnknownOperationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-10 07:32