As it currently stands, your endpoint would interpret cycles as a query parameter, meaning that it would expect the following kind of request:
GET /results?cycles=...
With a list of complex objects, this is not the standard approach. You could possibly pass the objects as /results?cycle1Id=abc&cycle1Date=22-10&cycle2Id=def&cycle2Date=10-10&..., but this would be extremely cumbersome, error-prone, and would require custom mapping on your end to make it work. Additionally, as far as I am aware, there is no standard for sending query array parameters.
Note also, in case you might have misconstrued: you cannot send a request body on a GET request - while the standard does not explicitly disallow this, almost every server's handling of GET does not accept (or just flatly ignores) a request body.
Instead, what you could do, is either:
- Change the endpoint to a
POST endpoint, passing the list of cycles (i.e. filters) as standard @RequestBody JSON. This would look as follows:
@PostMapping("results") public Result results(@RequestBody List<Cycle> cycles)
Now your request would expect:
POST /results { [ {"abc", "22-10"}, {"def", "10-10"} ] }
Since POST is allowed to pretty much do anything, it could also return a filtered response on this endpoint. This would however, not be very RESTful.
- Change your
GET to accept two lists of of simple (i.e. non-nested) objects, e.g. String and LocalDate.
@GetMapping("results") public Result results(@RequestParam List<String> ids, @RequestParam List<LocalDate> dates)
Which would then expect a request as follows:
GET /results?ids=abc,def&dates=22-10,10-10
as a comma-separated list. This is more in tune with RESTful endpoints, although it's also kind of cumbersome.
In the end, it seems like your endpoint is trying to do two things at once: filter on id and date. Since I am not sure what kind of logical work represents a cycle, perhaps these should be split up into two different endpoints, e.g.:
===> GET /results?dateFrom=22-10&dateUntil=23-10 <=== [abc, def] ==> GET /results/abc?dateFrom=22-10&dateUntil=23-10 <== abc detailed view
Where the /abc represents a singular object. Whether this represents a result or a cycle in your specific case, I cannot say. You'd have to evaluate that for yourself.