Multivalue query string support for REST endpoint in Lagom / Java

Hi All,

I’m trying to implement a rest endpoint with Java and lagom which should accept an array/multi value query string. According to lagom/lagom#1021 I understand that Lagom supports it.

ServiceCall definition looks like this:

ServiceCall<NotUsed, Vector> getProductsByIds(String code, Optional<java.util.List> productIds);

But looks like the productIds sent as query string are not getting mapped. Am I mapping correctly here or is this not supported in Lagom yet?

I’ve tried testing with query string different ways:

  • productIds=00011a0a-922a-4b5c-869e-6b9af4371bb9&productIds=09dc5472-5b1b-4630-9b5b-7d28356c6710
  • productIds=00011a0a-922a-4b5c-869e-6b9af4371bb9,09dc5472-5b1b-4630-9b5b-7d28356c6710
  • productIds[0]=00011a0a-922a-4b5c-869e-6b9af4371bb9&productIds[1]=09dc5472-5b1b-4630-9b5b-7d28356c6710

Wonder whether I am testing incorrectly or Lagom ignoring this query string itself? Please advise.

The first format is the correct one: productIds=00011a0a-922a-4b5c-869e-6b9af4371bb9&productIds=09dc5472-5b1b-4630-9b5b-7d28356c6710.

You might need to specify the type as List<String> productIds (or List<UUID>) rather than Optional<List>. If the parameter is missing, the list will be empty.

If you still need more help, please provide the code. At least the full service descriptor, but preferably a link to a complete example project that someone can run to reproduce the problem.

Thanks for the reply @TimMoore, that fixed it. :slight_smile: