I am creating an endpoint that will receive dates for server-side filtering. The code is as follows:
@RequestMapping(
value = "/test",
method = RequestMethod.GET,
produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}
)
@ResponseStatus(HttpStatus.OK)
public TestSummaryModel getTestSummaryByDate(
@RequestParam ZonedDateTime start,
@RequestParam ZonedDateTime end) {
return testService.getTestBetween(start, end);
}
When I try to call my endpoint, I get an HTTP 400 error. "The request sent by the client was syntactically incorrect."
I tried different date formats, but none of them worked. Am I missing something? I read about @DateTimeFormat, but although I added it, it didn't work.
@RequestParam @DateTimeFormat(pattern = "dd-MM-yyyy") ZonedDateTime start
This is an example of the query I am making:
http: // host / test-api / v1 / test-summary / test? start = 09-09-2015 & end = 09-09-2015
Thanks!
source
share