Posting data submissions using the KOBO Rest API

1,504 views
Skip to first unread message

Hussein Lightwalla

unread,
Dec 7, 2015, 4:38:50 AM12/7/15
to Kobo Users
Hello,

I'm having trouble forming the HTTP request in a correct format as expected for submitting data using the KOBO REST API. I'm trying to this from.net (C#). Could someone please assist me with a simple example of a code snippet of what this would look like?

Thank you!

Hussein

Tino Kreutzer

unread,
Dec 9, 2015, 10:56:31 AM12/9/15
to Kobo Users
Hi Hussein,
Are you trying to POST an XML or a JSON submission? There are some examples in our API documentation. 

If you've tried the examples on https://kc.kobotoolbox.org/api/v1/submissions unsuccessfully, could you paste your snippet so we can help troubleshoot? 

Best,
Tino

--
You received this message because you are subscribed to the Google Groups "Kobo Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.
To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kobo-users.
For more options, visit https://groups.google.com/d/optout.

Hussein Lightwalla

unread,
Dec 14, 2015, 7:37:55 AM12/14/15
to Kobo Users
Hey Tino,

Thanks for your reply. I've managed to submit data via CSV files as follows:

var client = new RestClient("https://kc.kobotoolbox.org/api/v1/forms/{pk}/csv_import");
client.Authenticator = new HttpBasicAuthenticator("user_name", "password");
client.AddDefaultUrlSegment("pk", "31045");
string file_path = Server.MapPath("~/myform.csv");
var request = new RestRequest(Method.POST);
request.AddFile("csv_file", file_path);
IRestResponse response = client.Execute(request);

but I still find it difficult with either JSON or XML. I think the main challenge is figuring out how exactly the XML file should be structured or how the JSON should be structured.

Thanks!

Tino Kreutzer

unread,
Dec 30, 2015, 11:24:03 AM12/30/15
to Kobo Users

Hi Hussein,

For importing XML, did you try using the exact format of XML created by KoBoCollect? The default format is

<?xml version='1.0' ?>
<your_form_id id="your_form_id">
<formhub><uuid>xxxxxxxxxxxxxxxxxxxxxxx</uuid></formhub><q1>some text</q1><q2>some text</q2><meta><instanceID>uuid:yyyyyyyyy</instanceID></meta>
</your_form_id>

Best,
Tino


Hussein Lightwalla

unread,
Dec 31, 2015, 6:42:27 AM12/31/15
to Kobo Users
Hey Tino,

I'll give this a shot. Thanks!

Kind regards,

Hussein
Reply all
Reply to author
Forward
0 new messages