Updating Records via the API

@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