Api网关“;格式错误的lambda代理响应“;从java返回字符串时

Api网关“;格式错误的lambda代理响应“;从java返回字符串时,java,amazon-web-services,aws-lambda,aws-api-gateway,Java,Amazon Web Services,Aws Lambda,Aws Api Gateway,我不知道该怎么办,我已经查了很多问题,但没有一个使用java。我还试图直接回复,但即使这样也不能正常工作。网关不会返回错误,但会返回一个带空主体的200(应该是带主体的300)如果您不打算使用,则需要确保响应中的字段正确无误。如您所见,正文只是一个字符串: Mon Sep 28 09:30:27 UTC 2020 : Received response. Status: 200, Integration latency: 16 ms Mon Sep 28 09:30:27 UTC 2020 :

我不知道该怎么办,我已经查了很多问题,但没有一个使用java。我还试图直接回复,但即使这样也不能正常工作。网关不会返回错误,但会返回一个带空主体的200(应该是带主体的300)

如果您不打算使用,则需要确保响应中的字段正确无误。如您所见,
正文
只是一个字符串:

Mon Sep 28 09:30:27 UTC 2020 : Received response. Status: 200, Integration latency: 16 ms
Mon Sep 28 09:30:27 UTC 2020 : Endpoint response headers: {Date=Mon, 28 Sep 2020 09:30:27 GMT, Content-Type=application/json, Content-Length=68, Connection=keep-alive, x-amzn-RequestId=string, x-amzn-Remapped-Content-Length=0, X-Amz-Executed-Version=$LATEST, X-Amzn-Trace-Id=root=string;sampled=0}
Mon Sep 28 09:30:27 UTC 2020 : Endpoint response body before transformations: "{\"statusCode\":300,\"headers\":{},\"body\":{\"key1\":\"value1\"}}"
Mon Sep 28 09:30:27 UTC 2020 : Execution failed due to configuration error: Malformed Lambda proxy response
Mon Sep 28 09:30:27 UTC 2020 : Method completed with status: 502
私有整数状态码;
私有映射头;
私有字符串体;
私有布尔值是base64编码的;

通过查看官方代码示例,我找到了类
APIGatewayProxyResponseEvent
,我通过实现
可序列化
并公开getter,使自己的
响应
类发挥作用。但是,我无法使它与json字符串一起工作

Mon Sep 28 09:30:27 UTC 2020 : Received response. Status: 200, Integration latency: 16 ms
Mon Sep 28 09:30:27 UTC 2020 : Endpoint response headers: {Date=Mon, 28 Sep 2020 09:30:27 GMT, Content-Type=application/json, Content-Length=68, Connection=keep-alive, x-amzn-RequestId=string, x-amzn-Remapped-Content-Length=0, X-Amz-Executed-Version=$LATEST, X-Amzn-Trace-Id=root=string;sampled=0}
Mon Sep 28 09:30:27 UTC 2020 : Endpoint response body before transformations: "{\"statusCode\":300,\"headers\":{},\"body\":{\"key1\":\"value1\"}}"
Mon Sep 28 09:30:27 UTC 2020 : Execution failed due to configuration error: Malformed Lambda proxy response
Mon Sep 28 09:30:27 UTC 2020 : Method completed with status: 502
private Integer statusCode;
private Map<String, String> headers;
private String body;
private Boolean isBase64Encoded;