Please note the creation of a new export through the API is synchronous.
As a result, the HTTP request may time out if there’s a lot of data.
Make sure your API key can create exports in Lucca Timesheet.
1
Preliminaries
You first need to retrieve the export-configuration identifier.The export-configuration identifier
exportConfigurationId
is the second integer URL path parameter
when browsing the graphical interface for Lucca Timesheet export feature. For example, if the UI URL looks
like this when browsing to the export-configuration: https://example.ilucca.net/timmi-timesheet/legacy-settings#/export/1/3/latest
,
then the identifier is 3
.Then, you may want to retrieve the identifier of the latest successful export, it will
help you track the progress of any new export you’ll then create. This can be achieved through the API:2
Trigger an export
When creating an export, two parameters are required:Then, you can forge the following HTTP request:
- A date-time
endsAt
, which indicates that all elements prior to it should be exported. Format isYYYY-MM-DDT00:M00:00
(time component must be equal to midnight). - An export-configuration ID
configurationId
(cf “preliminaries” above).
Chose the
endsAt
date carefully when creating a payroll variables export, as you may have calculation rules that handle time on a weekly basis (triggered on sundays).
If so, consider exporting on a Monday at midnight (i.e. “00:00:00”) rather than on the first day of the next month.The export creation is a synchronous process. As a result, the server will only respond once the export has been fully and successfully generated.
This can take some time, and even time out. Your safest bet is to abort the connexion, and track the export creation progress by polling (cf. below).
3
Track export progress
In order to figure out if the export is complete or not, you can poll the server with the following HTTP request
(you need the
lastExportId
and exportConfigurationId
retrieved in the “preliminaries” step):If the export was successful, then take note of its id:
generatedExportId = data.items[0].id
.Problem is: you will never know if the export has actually failed.Therefore, you may try creating (cf. step #2) a new export again after an arbitrary
amount of time (say, one hour) has passed, but your polling requests still return
an empty
items
array, as your previous request has probably failed.4
Retrieve the export content
If the export was successfully created, you may retrieve its content with the following HTTP request: