Hi, new guy here. Having a problem reading query parameters in a java lambda function behind a load balancer.
The question is "where are the query parameter values?"
The setup is this: we created a stream/jersey based lambda from a template which got us a StreamLambdaHandler class implementing RequestStreamHandler and specifically a handleRequest(InputStream, OutputStream, Context) method. This method sends the inputStream to a JerseyLambdaContainerHandler member which handles parsing of the stream and calls the http handler methods we created and annotated, code follows below. The load balancer just forwards calls to the lambda function.
The problem is that query parameters are not received in the http handler methods. But they do reach the RequestStreamHandler - we saw this by logging the inputStream; this is what we saw:
{"requestContext":{"elb":{"targetGroupArn":"arn:aws:elasticloadbalancing:eu-west-1:somewhere:targetgroup/blue/something"}},"httpMethod":"POST","path":"/timereg/employee/","queryStringParameters":{"cert":"1","company":"1","date":"1","eid":"17","id":"1"},"headers":{"accept":"*/*","host":"api-gateway-lb-somethingelse:9999","user-agent":"curl/7.64.0","x-amzn-trace-id":"Root=1-5d8b7c0e-f2ab4da860b54450ce8a2234","x-forwarded-for":"33.44.55.66","x-forwarded-port":"9999","x-forwarded-proto":"http"},"body":"","isBase64Encoded":false}
But once the call reaches our GET handler the parameters are gone. Code:
@Path( "/timereg" )
public class TimeRegistration {
@GET
@Produces( MediaType.APPLICATION_JSON )
@Consumes( MediaType.WILDCARD )
@Path( "/employee" )
public Response get( @QueryParam("id") String id, @QueryParam("eid") String eid, @QueryParam("company") String company, @QueryParam("date") String date, @QueryParam("cert") String cert, @Context UriInfo uriInfo )
{
logger.info(uriInfo.getPath());
logger.info(String.format( "queryparams: %s", uriInfo.getQueryParameters()));
logger.info(String.format( "pathparams : %s", uriInfo.getPathParameters()));
long empId = Long.parseLong( eid ); // NumberFormatException: null
//....cut
The log output from the code above is:
"timereg/employee" (as expected)
"queryparams: {}" ( why? )
"pathparams : {}" ( why? )
We call it with curl:
curl -v 'http://api-gateway-lb-somethingelse:9999/timereg/employee/?eid=17&company=1&id=1&cert=1&date=1'
We would be very happy if anyone could point us in the right direction. Thank you for reading.