From my understanding, if you return the following json string: {"headers":{"Content-Type":"application/json"},"body":"hello world","statusCode":200}
then when visiting the page https://....eu-west-2.amazonaws.com/prod/, you should see the phrase "hello world" written. Instead, I get {"message": "Internal server error"}
Below is the JAVA code I am using to return the above json string:
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import org.json.simple.JSONObject;
import java.util.Map;
public class Handler implements RequestHandler<Map<String, String>, JSONObject>{
@Override
public JSONObject handleRequest(Map<String, String> stringStringMap, Context context) {
JSONObject obj = new JSONObject();
JSONObject obj2 = new JSONObject();
obj2.put("Content-Type", "application/json");
obj.put("statusCode", 200);
obj.put("headers", obj2);
obj.put("body", "hello world");
return obj;
}
}
What am I doing wrong? It works fine on the console when I test the function, but when I go to the page of the API it gives me an internal server error.
java.lang.Stringout of START_OBJECT token'