How do we connect Collecton to another system (DHIS2, REST API...)?

We need to send aggregates to our national system and fetch lists from another application. Can Collecton do that?

Yes, with the project’s automations. There is no ready-made connector: each exchange is a small script, written in the project (with the prompt or by hand), that calls the other system’s API.

Possible triggers

  • a schedule (every day at 6 am, on the 1st of the month…), with its time zone;
  • a form being received;
  • a subject or a place being created or edited;
  • an inbound call: the other system calls Collecton at a dedicated address, with a key.

What the script can do

  • call the other system (app.http: GET, POST, PUT, PATCH, DELETE) through a named connection;
  • write the result of a call into Collecton: places, subjects, reports, external ids (to link a Collecton subject to its counterpart elsewhere);
  • keep a state from one run to the next (for example, the date of the last send).

Connections and secrets

A connection’s address, authentication mode and secret are entered in the admin, the project’s Automations card, Connections section (add, test, edit). The secret is encrypted and never shown again; the project files only name the connection, and a script can only call its connection’s address.

Follow-up

The same card lists the automations, lets you Run now a schedule, and shows the details of each run: trigger, calls made, effects, error, log.