How to Download Reports
Introduction
This guide is aimed at helping you generate Timesheet reports directly through API requests.
Prerequisites
You will need:
- (required) Your domain name
{yourDomain}
, eg: “https://myawesomecompany.ilucca.net”. - (required) An API key
{apiKey}
that has report generation rights.
Guide
A report
can only be generated from an existing report-template
, referenced by its unique identifier templateId
, for which your API key must have access to.
If an existing report-template
is publicly available, you can generate a report
from it.
But in most cases, you will need to create a dedicated report-template
for your API key.
1. Create a report-template
As the resource is not yet documented, the easiest way is to create a new report-template
through Timmi Timesheet user interface, then copy-paste the generated payload to make your POST request /report-templates
with your API key.
For example :
The created report-template
{id}
will be answered in reponse.
2. Generate a new report from this report-template
You can now generate a report through /timmi-timesheet/api/reports
with :
- The
report-template
{id}
you just created. - The start date of the report to generate
{reportStartDate}
. If left null, default date from thereport-template
is applied. - The end date of the report to generate
{reportEndDate}
. If left null, default date from thereport-template
is applied.
These will be used as parameters in the following request:
Which response should look like:
This response contains, among other things:
- the identifier
(integer) id
of the created report, to be kept carefully as the{reportId}
- the status
(string) status
of the generation of its content, which is an enum:
Background process
The generation of a report content is a background process. As long as this process is not complete, the report status stays pending
. Once the report is complete, its status is set to done
. May an error be encountered while generating its content, then its status is set to error
.
The report content can only be viewed and downloaded once it is done
.
The generation of the report is an asynchronous process. In practice, when the POST request is received, the server immediately responds with a 200 OK
if successful, otherwise an error code is displayed.
3. Track report background building progress
The next request should be repeated at regular intervals (say, every 10 seconds) until the response indicates a done
status (rather than pending
).
If request is met with an error, the status error
will be returned. In this case, it will be necessary to try creating a new report and if the error occurs again, please contact our support.
Here, {reportId}
should be equal to the identifier of report recovered in response to the previous POST:
4. Download the finalized report data
Once the content of the report is generated (status done
), it can be downloaded in a CSV file:
Or in Excel format:
Reports expire after 24h, and will be deleted as soon as another report from any report-template is generated.
Was this page helpful?