Changing Form Choices via API, need guidance

Hi @paulsermon, you can take either route to update your form.

  1. Upload via API: I also couldn’t find documentation, but you can do the following. If your current project has the asset UID of aW5HJb2gDhpATTaAAHZdxB and you want to replace the current form with a new form of name new-form.xlsx (with a local path of /path/to):
curl -X POST https://kf.kobotoolbox.org/api/v2/imports/ \
  -F file=@/path/to/new-form.xlsx \
  -F destination=https://kf.kobotoolbox.org/api/v2/assets/aW5HJb2gDhpATTaAAHZdxB/ \
  -H "Authorization: Token <your secret token>"

You should get a JSON response from the request that looks something like:

{
  "uid": "it76ukZ57Ks3oSEYrgyTzC",
  "url": "https://kf.kobotoolbox.org/api/v2/imports/it76ukZ57Ks3oSEYrgyTzC/",
  "status": "processing"
}
  1. You can update the form with a PATCH request directly to https://kf.kobotoolbox.org/api/v2/assets/aW5HJb2gDhpATTaAAHZdxB/, updating the content with your new form in JSON format.

Note that for either of these routes, you need to redeploy the project to make it live (you can do this through the API too). An example of this and other useful API tricks can be seen here:

4 Likes