On the beginning I would like to mention that I just start learning AWS tools.
I have two request handlers created with Java. Both of them have the same handleRequest method which looks like one below
public class SecondHandler implements RequestHandler<JSONObject, List<Candidate>> {
@Override
public List<Object> handleRequest(JSONObject request, Context context) {
List<Object> objectList = new ArrayList<>();
System.out.println(request + " <<");
String isActive = String.valueOf(request.getString("isActive"));
if(!isActive) return objectList;
for(Object obj : objectList) {
// here will go logic
}
return objectList;
}
}
First method is used to return some list of object without sending any arguments to it. And it work fine when calling it with AWS lambda, and when using AWS Gateways.
Second method I am trying to call with sending JSONObject with one filed like
{
"isActive" : "yes"
}
But when I do the test I am getting error "JSONObject[\"isActive\"] not found.". And I am sure that this is related to my JSONObject request argument, because when I am changing its type to Map<String, String> it works fine, I am getting what I want when using AWS Lambda. But with Map in place when I try to call this with AWS Gateway I am getting
{ "message" : "Internal server error" }
When checking the logs I can see there is problem with parsing. So basically AWS Gateway can not parse Map<String, String>.
Could someone tell me, what I do not understand about lambda and gateways? Why those tools have such problem with parsing simple JSON? What I should do?
PS. I also had the issue with parsing on the first method, when using Map<String, String> that is why I decided to use JSONObject, and that solved the issue for first method.