I am trying to following best practices when creating a REST endpoint for my resource Dashboard
. So I am planning to create POST for creation, PUT for update and GET for fetching the Dashboard
in my spring mvc controller.
However, I have a validate
API endpoint as well, that does not save nor update anything in the database, so I was planning to use the GET
HTTP method for the validate
endpoint. But there are a lot of parameters I need to pass to this endpoint, so I'd prefer if this would be a @RequestBody
and not just usual request parameters, because GET
has a limit that I can exceed.
Should I use POST
instead of GET
even though I am not planning to make any database changes?
@PostMapping("/dashboards/{id}/validate")
public ResponseEntity<VisualMetadata> validateVisualMetadata(@PathVariable String id,
@Valid @RequestBody DashboardDto requestDto) {
}
UPD: DashboardDto
does not just have primitives such as String/long/integer, but also has nested complex data types such as Axis
and Metric
class DashboardDto {
String id;
Axis axis;
List<Metric> metrics;
}