以下是AWS lamdba java代码,它接收来自AWS API Gateway的输入。我在下面的java代码: -
public class LambdaFunctionHandler implements RequestStreamHandler {
JSONParser parser = new JSONParser();
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException {
LambdaLogger logger = context.getLogger();
logger.log("Loading Java Lambda handler of ProxyWithStream");
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
JSONObject response = new JSONObject();
String name = "World";
String responseCode = "200";
try {
JSONObject event = (JSONObject)parser.parse(reader);
if (event.get("queryStringParameters") != null) {
JSONObject qps = (JSONObject)event.get("queryStringParameters");
if ( qps.get("name") != null) {
name = (String)qps.get("name");
}
if (qps.get("httpStatus") != null) {
responseCode = qps.get("httpStatus)").toString();
}
}
//response.put("statusCode", responseCode);
response.put("rohit", event.toJSONString());
} catch(ParseException pex) {
response.put("statusCode", "400");
response.put("exception", pex);
}
logger.log(response.toJSONString());
OutputStreamWriter writer = new OutputStreamWriter(outputStream, "UTF-8");
writer.write(response.toJSONString());
writer.close();
}
}
当我改变
时response.put("body", event.toJSONString());
到
response.put("rohit", event.toJSONString());
显示错误: -
{
"message": "Internal server error"
}
先谢谢你的帮助......