Amazon connect hello world lambda 集成总是出错

Amazon connect hello world lambda integration always errors

我有一个简单的 java lambda 函数,它具有以下代码

       public String handleRequest(Map<String, Object> input, Context context) {
        Map<String, String> result = new HashMap<String, String>() {{
           put("status", "success");
        }};
        String resultStr = new GsonBuilder().create().toJson(result, HashMap.class);
        logger.info("ended function successfully " + resultStr);

        return resultStr;
    }

我可以在 cloudwatch 中看到以下几行

    2020-07-10T17:52:26.198-07:00
    START RequestId: 1b0ff049-3a61-4874-9172-9bee142dc076 Version: $LATEST
    2020-07-10T17:52:26.203-07:00
    2020-07-11 00:52:26 INFO KVSTriggerLamda:53 - ended function successfully {"result":"Success"}
    
    2020-07-10T17:52:26.204-07:00
    END RequestId: 1b0ff049-3a61-4874-9172-9bee142dc076

My Amazon connects 调用触发此功能,并根据状态播放“成功”或“错误”的简单提示。我总是得到“错误”

正确的return值应该是多少?我遵循了 aws 文档,其中指定我需要提供一个简单的平面 JSON return 值。

我终于通过返回地图本身使它工作了。

Map<String, String> result = new HashMap<String, String>() {{
   put("status", "success");
}};
return result;

感谢@tgdavies 的评论 -

The output type can be an object or void. https://docs.aws.amazon.com/lambda/latest/dg/java-handler.html#java-handler-types