When trying to test my AWS REST API POST method that's connected to my Java Lambda function, I get an error {"message": "Internal server error"} when I pass in: userID=5&name=test as a query string like so: enter image description here
I want to do the same as thing as going into Lambda Test console and typing in:
{ "userID": 5 "name": "test" } in the "Event JSON" part (which works fine in Lambda), but when I try to replicate it through the API, it doesn't work.
This is my Java code:
import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.LambdaLogger; import com.amazonaws.services.lambda.runtime.RequestHandler; public class Launcher implements RequestHandler<Launcher.CompanyRecord, String>{ public String handleRequest(CompanyRecord event, Context context) { return String.valueOf(event.userID) + event.name; } record CompanyRecord(int userID, String name) { } } I've also tried passing in
{ "userID": 10, "name": "test" } in the Headers and Request Body (independently), but I still get the same {"message": "Internal server error"}