Date params in /history/task REST API don't apply

When i include date filtering to task history request - they dont apply and results stay the same:

And in results i see all tasks, including old:
“startTime”: “2018-12-14T18:50:50”,
“endTime”: “2018-12-14T18:51:29”

All ideas appreciate!

1 Like

The problem was that in date 2019-02-23T14:42:45.000+0300 ‘+’ must be url-encoded.
May be it will be better to write about this detail in documentation.


HI All,

Above solution is working fine in postman but it is not working in java API. I am using following statement to do that.

String url = “https://localhost/api/history/task?startedAfter=2020-10-15T15:21:30.104%2B0900”;

ResponseEntity result = restTemplate.getForEntity(url, String.class);

Could anyone please share correct example for the same.

Thanks in advance.

1 Like

Hi, Sanjay!
Write in java url ‘+’ sign as it is. Because spring do url-encoding itself too (and converts %2B to %252B)

Thanks Raliev for taking out time.
I tried this but It is throwing exception. Please find below logs.

Exception in thread “main” org.springframework.web.client.HttpClientErrorException$BadRequest: 400 400: [{“type”:“InvalidRequestException”,“message”:“Cannot set query parameter ‘startedAfter’ to value ‘2020-10-15T15:21:30.104 0900’: Cannot convert value “2020-10-15T15:21:30.104 0900” to java type java.util.Date”}]

Please find below code snippet.

String strDate=“2019-10-15T15:21:30.104+0900”;
String url = “https://localhost/api/history/task?startedAfter=” + strDate;

ResponseEntity result = restTemplate.getForEntity(url, String.class);

@sanjay.chaurasia i’ve tested your code snippet - its working. So the only reason, i think, will be that your Camunda dateTime format is another.
The simplest way to test it - run /history/task without parameters. You will see list of tasks, and in the dateTime fields there will be real dateTime format on you server., e.g. "startTime": "2020-01-31T11:17:08.587+0300" or "startTime": "2020-01-31T11:17:08.587".
The ?startedAfter= parameter in your query must be in the same format.
About dateTime format you can read

1 Like

@raliev I checked and found that default date format is used.
“startTime”: “2019-01-07T10:22:15.845+0900”, This is the time I got from /history/task API.

Though It is completely working fine If I hit the same URL from browser and postman but it is not working with JAVA API.

Please find below URL which is working fine in postman and browser but in java, it is not working.

@sanjay.chaurasia , so the only way - to debug your code: e.g. set break point in RestTemplate.getForEntity(url, class) and check the result url, which will be called by Spring. It should be equal to the url, that you mentioned above (https://localhost/api/history/task?startedAfter=2019-10-15T15:21:30.104%2B0900)

Yes, I checked the URL in debug mode. Same url is passing in RestTemplate.getForEntity(url, class). I wonder why it is not working while the same URL is working with Postman. I am completely fed up with this.

Could you please share your code snippet that you have tested. May be I am missing something :frowning: