这个问题可能是由于您的API网关集成配置中存在错误引起的。在API集成的设置中,您需要将集成类型设置为AWS服务,并选择目标为EventBridge。下面是一个示例集成配置:
"resources": [
{
"path": "/myApi",
"httpMethod": "POST",
"integration": {
"type": "AWS",
"uri": "arn:aws:apigateway:us-east-1:events:action/PutEvents",
"passthroughBehavior": "when_no_templates",
"httpMethod": "POST",
"requestTemplates": {
"application/json": "{\n \"detail\": $input.json('$'),\n \"detail-type\": \"My Detail Type\",\n \"source\": \"com.mycompany.myapp\"\n}"
},
"credentials": "arn:aws:iam::1234567890:role/MyRole",
"integrationResponses": [
{
"statusCode": "200"
}
]
}
}
请确保uri正确设置为arn:aws:apigateway:{Region}:events:action/PutEvents并且credentials正确指向一个允许PutEvents操作的角色。如果您已经使用了正确的集成配置,但仍然遇到此错误,请确保您的IAM用户或角色具有PutEvents操作的权限。