Locations - problem with array/list as optional param

450 views Asked by At

Request A: http://localhost:8080/api/organizations/1/scenarios?perProducts=1,

Request B: http://localhost:8080/api/organizations/1/scenarios?perProducts=1,2

My Location class:

            @Location("/scenarios")
            data class Scenarios(
                val organization: Organization,
                val startValue: Int = 0,
                val perPage: Int = 10,
                val perProducts: List<Int> = listOf(),
                val byName: String = ""
            )

If I add one product id to path (request a) all is ok, but if I add two (request b) or more ids I get "bad request" in response. What do I wrong?

1

There are 1 answers

1
Михаил Нафталь On BEST ANSWER

Try this one:

http://localhost:8080/api/organizations/1/scenarios?perProducts=1&perProducts=2

Locations under the hood uses Data Convertion feature, and this is a way it handles multiple values.