Reputation: 46238
Redmine API can serve time entries in JSON.
$ curl -X GET \
'https://my_redmine/time_entries.json' \
-H 'X-Redmine-API-Key: my_api_key'
{"time_entries":[{"id":14212,"project":{"id":73,"name":"Project 1"},"issue":{"id":5488},"user":{"id":5,"name":"John SMITH"},"activity":{"id":8,"name":"Grouillot"},"hours":8.0,"comments":"dsgsdsdh","spent_on":"2020-03-09","created_on":"2020-01-07T14:03:58Z","updated_on":"2020-01-07T14:33:52Z", ...
Now I need to get them aggregated and I'd rather use the built in report aggregation feature than doing it myself after having fetched all the required time entries.
Let's say we have these time entries
+------+----------+-------+------------+
| user | issue_id | hours | spent_on |
+------+----------+-------+------------+
| 1 | 42 | 4 | 2020-01-01 |
| 1 | 43 | 4 | 2020-01-01 |
| 2 | 42 | 8 | 2020-01-01 |
+------+----------+-------+------------+
If I want them to be aggregated by user, here is what need to get
+------+-------+------------+
| user | hours | spent_on |
+------+-------+------------+
| 1 | 8 | 2020-01-01 |
| 2 | 8 | 2020-01-01 |
+------+-------+------------+
There doesn't seem to be any way to do that in the current REST API
But since a report can be generated by CSV with this kind of query
https://my_redmine/time_entries/report.csv?columns=day&criteria%5B%5D=user
I naively though we could use it like
$ curl -X GET \
'https://my_redmine/time_entries/report.json?columns=day&criteria%5B%5D=user' \
-H 'Accept: application/json' \
-H 'X-Redmine-API-Key: my_api_key'
But no luck, it returns a redirection to an HTML login form.
Even fetching the CSV with the API key or a basic auth doesn't seem possible.
Does anyone would have any idea about getting the time entries aggregated with a REST HTTP query ?
Upvotes: 1
Views: 1305