REST request to retrieve a value from an external source

I have looked into this, and here is a workaround. It means that some of the suggestions posted here and in https://support.kobotoolbox.org/en/articles/978826-pull-data-functionality-in-kobotoolbox are not correct.

  • Pulldata from an URL is not supported. I am not sure about this, because it is tempting to use it when you upload a media csv file, but let’s wait for someone knowing better.
  • So we must try to use the “manual copy csv-method” by using a sync tool. I used SMBSyn2 on Android, which works nicely.
  • On Android, form media are stored in subdirectories of /storage/emulated/0/odk/forms. When you have several versions of a form, there are multiple directories disambiguated by (2), (3).
  • Use SMBSync2 to synchronize all files in this folder with all non-empty subfolders with some Samba-Share - with other apps you can also synchronize with some network share, but the Sambo-solution was good enough for me. Make sure you have selected the advanced options, with “do not overwrite newer files”. You need this step to find out how the directory structure is.
  • Do the synchronization. Edit the CSV.imported-file (but read the full text first), or replace it by a new one. You need to make sure that you realy picked the latest version of the subdirectory, some clever script could do this automatically.
  • Create another task in SmbSync2 to COPY newer files to the device. Do the sync.
  • Test by entering new data into a form. Be surprised that things have not changed, old file still active.

Why? Kobo does not care about the CSV.imported file, because it looks up what is in the SQlite database, without checking that the CSV.imported had been changed.

So do the following:

  • Do not edit the CSV.imported file on your Samba share, but edit the SQLite database xxx.db with a standard tool - I use https://sqlitestudio.pl/. Then copy the file back to your device. This means that you can restrict the synchronization to *.db files only.

This procedure is a mess, and will not work reliably in practice. Correct me when I am wrong, but please provide an example.

Some api tool to upload CSV files and update the database are required. Clearly some method to retrieve lookups from a REST API would be helpful, but that’s a major undertaking to handle the asynchronous task. I found a commercial solution (123 something) that looked right with “@javascript”, but alas, no HTTP, nothing asynchronous.

Frustrated…