Skip to main content

Developer README for the commcare adaptor


Language CommCare

Language Pack for interacting with the CommCare API.

Accepted X-Form Spec from Dimagi: Accepted X-Form Spec for Cases from Dimagi:


Sample configuration

The "appId" is the UUID which designates your commcare project as different from everyone elses. It can be found in the URL of your application when you first enter it from the project screen. I.e., the last part of this url:

Note that the username is your full email address.

"appId": "the-long-uuid-in-the-url-that-designates-a-unique-commcare-project",
"password": "shhh",
"username": "",
"applicationName": "some-proof-of-concept",
"hostUrl": ""

fetchReportData to pull aggregate data from CommCare

It takes 3 arguments: reportId, params, and postUrl.

{ limit: 10, offset: 2, state: 'Vermont' },

simple body target:

<data xmlns="">

complex body target:

<?xml version='1.0' ?>
<data uiVersion="1" version="17" name="New Form" xmlns:jrm="" xmlns="">
<n0:case case_id="ddb8e2b3-7ce0-43e4-ad45-d7a2eebe9169" user_id="user-xxx-eve" date_modified="2013-04-19T16:53:02.799-04" xmlns:n0="">
<n1:meta xmlns:n1="">
<n2:appVersion xmlns:n2="">CommCare ODK, version "2.4.1"(10083). App v19. CommCare Version 2.4. Build 10083, built on: March-12-2013</n2:appVersion>

Submitting data to CommCare HQ

Submit an XLS file

This function bulk submit a JSON object as xls file to CommCare HQ

submitXls([{ name: 'Mamadou', phone: '000000' }], {
case_type: 'student',
search_field: 'external_id',
create_new_cases: 'on',


Here we're just building the most basic JSON object, that will be converted to an XML object and posted as the element.

field('@', function (state) {
return {
field('paitent_namentosh', dataValue('first_name')),
field('question2', 'Some answer here.'),
field('question3', 'HKS'),
field('question4', 'item1'),
field('question5', 69855),
field('question6', 12)

An open rosa form submission body should look like this:

<?xml version="1.0" ?>
<data name="Patient Registration" uiVersion="1" version="9" xmlns="" xmlns:jrm="">
<n0:meta xmlns:n0="">
<n1:appVersion xmlns:n1="">CommCare ODK, version &quot;2.22.0&quot;(370023). App v9. CommCare Version 2.22. Build 370023, built on: July-22-2015</n1:appVersion>

So the JSON emitted by your expression should look like this:

"data": {
"name": "Patient Registration",
"uiVersion": "1",
"version": "9",
"xmlns": "",
"xmlns:jrm": "",
"paitent_namentosh": "Taylor",
"question2": " Moruki",
"question3": "Hks",
"question4": "item1",
"question5": "69855",
"question6": "12",
"n0:meta": {
"xmlns:n0": "",
"n0:deviceID": "358239055789384",
"n0:timeStart": "2015-08-21T16:21:59.807+02",
"n0:timeEnd": "2015-08-21T16:22:15.987+02",
"n0:username": "openfn",
"n0:userID": "5fe615b3af2834cb5dca59f7466d6174",
"n0:instanceID": "195e79eb-d823-46fe-9e4f-59b8327d5db2",
"n1:appVersion": {
"xmlns:n1": "",
"$t": "CommCare ODK, version \"2.22.0\"(370023). App v9. CommCare Version 2.22. Build 370023, built on: July-22-2015"


Clone the adaptors monorepo. Follow the Getting Started guide inside to get set up.

Run tests using pnpm run test or pnpm run test:watch

Build the project using pnpm build.

To just build the docs run pnpm build docs