Updating Records via the API

Great to see the [new bulk import feature] (https://protect-us.mimecast.com/s/w3MBCpYKy5Un42DvH7yg11).

We are interested in being able to download, clean and update data.

Is there a timeline for the bulk update tool to support:

i) Updates to records
ii) Running via an API call

We may have funds to support these enhancements and would be happy to have a dialogue on moving this forward.

Thanks for your message. The features you describe are not yet planned. Could you describe in more detail what you’d like to do? Is the goal to upload XML submissions in bulk and overwrite existing submissions where the UUIDs are equal?

John

We’d be willing to adopt to the approach/architecture that works best for the broader community.

We would want something that could be automated, so ideally it would run over a RESTful API with submission of XML matching the format already used in KoboToolBox/

As you say, the approach would overwrite where UUID matched and the XML had the write structure.

Thanks for the quick response.

Jonathan

  • 1 347 566 0030 |skype: wcs.org_jpalmer | Calendar

@palmernet After discussing with @jnm and based on our recent discussion I can confirm that it is in fact already possible to do these batch updates via the API, using the endpoint http://kc.kobotoolbox.org/api/v1/submissions. This is the same endpoint used to submit new records.

As per OpenRosa, the POST request needs to specify the original UUID as well as a newly generated UUID to identify the edited version. An edit should therefore have <deprecatedID>my-old-submission-id</deprecatedID> and <instanceID>my-newly-generated-id-for-this-edit</instanceID>.

This is the method which which Enketo is used to edit submitted data in the URL. If you’re coming up with an API script that pushes back edited data into KoBoToolbox please share the script, I’m sure others will be interested in that as well.

Here is an example:

curl -X POST \
  https://kc.kobotoolbox.org/api/v1/submissions.json \
  -H 'Authorization: Token <yourAPItoken>' \
  -H 'Content-Type: application/json' \
  -d '    {
    	"id": "<yourformID / kpi asset ID>",
    	"submission":
   
		    {
		        "last_name": "Suresh",
		        "first_name":"Ameen",
		        "meta": {
		        	"instanceID": "uuid:8992c3c2-3418-4ba9-a8e2-b00e03ea36b6",
		        	"deprecatedID": "uuid:8992c3c2-3418-4ba9-a8e2-b00e03ea36b3"
		        }
		        
		    }
    } '
2 Likes