kobotoolbox@4.1.0
This adaptor exports the following namespaced functions:
- http.get(path, [options])
- http.post(path, data, [options])
- http.put(path, data, [options])
- http.request(method, path, [options])
This adaptor exports the following from common:
- alterState()
- cursor()
- dataPath()
- dataValue()
- each()
- field()
- fields()
- fn()
- fnIf()
- group()
- lastReferenceValue()
- merge()
- sourceValue()
Functions
getDeploymentInfo
getDeploymentInfo(formId) ⇒ Operation
Get deployment information for a specific form. Calls /api/v2/assets/<id>/deployment/
.
Param | Type | Description |
---|---|---|
formId | string | Form Id to get the deployment information |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | an object containing deployment information |
Example |
getDeploymentInfo('aXecHjmbATuF6iGFmvBLBX');
getForms
getForms() ⇒ Operation
Make a request to fetch all survey forms accessible to the authorized user. Calls /api/v2/assets/?asset_type=survey
.
This operation writes the following keys to state:
State Key | Description |
---|---|
data | an array of form objects |
Example |
getForms();
getSubmissions
getSubmissions(formId, [options]) ⇒ Operation
Get submissions for a specific form. Calls /api/v2/assets/<formId>/data/
Param | Type | Default | Description |
---|---|---|---|
formId | string | Form Id to get the specific submissions | |
[options] | object | {} | Options to control the request |
[options.sort] | object | Field and direction to sort submissions by. | |
[options.query] | object | Query options to filter the submissions. See query operators http://docs.mongodb.org/manual/reference/operator/query/. | |
[options.start] | number | 0 | The index of the first submission to return. |
[options.limit] | number | 30000 | Maximum number of submissions to fetch. Pass Infinity to disable the limit and download all submissions |
[options.pageSize] | number | 10000 | Limits the size of each page of submissions. Maximum value is 30000. |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | an array of submission objects |
Example: Get submissions for a specific form |
getSubmissions('aXecHjmbATuF6iGFmvBLBX');.
Example: Get all submissions for a specific form
getSubmissions('aXecHjmbATuF6iGFmvBLBX', { limit: Infinity });
Example: Get form submissions with a query
getSubmissions('aXecHjmbATuF6iGFmvBLBX', { query: { _submission_time:{ $gte: "2025-03-12T21:54:20" } } });
Example: Get form submissions with sorting
getSubmissions('aXecHjmbATuF6iGFmvBLBX', { sort: { _submission_time: -1 } });
Example: Get form submissions with specific start index
getSubmissions('aXecHjmbATuF6iGFmvBLBX', { start: 10 });
http
These functions belong to the http namespace.
http.get
get(path, [options]) ⇒ operation
Make a GET request to any KoboToolbox endpoint.
Param | Type | Default | Description |
---|---|---|---|
path | string | path to resource | |
[options] | HTTPRequestOptions | {} | An object containing query params and headers for the request |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the KoboToolbox server (excluding the body) |
references | An array containing all previous data objects |
Example: GET assets resource |
http.get('assets')
http.post
post(path, data, [options]) ⇒ operation
Make a POST request to a KoboToolbox endpoint
Param | Type | Default | Description |
---|---|---|---|
path | string | path to resource | |
data | any | the body data in JSON format | |
[options] | HTTPRequestOptions | {} | An object containing query params and headers for the request |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the KoboToolbox server (excluding the body) |
references | An array containing all previous data objects |
Example: Create an asset resource |
http.post(
'/assets/',
{
name: 'Feedback Survey Test',
asset_type: 'survey',
},
);
http.put
put(path, data, [options]) ⇒ operation
Make a PUT request to a KoboToolbox endpoint
Param | Type | Default | Description |
---|---|---|---|
path | string | path to resource | |
data | any | the body data in JSON format | |
[options] | HTTPRequestOptions | {} | An object containing query params and headers for the request |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the KoboToolbox server (excluding the body) |
references | An array containing all previous data objects |
Example: Update an asset resource |
http.put(
'assets/a4jAWzoa8SZWzZGhx84sB5/deployment/',
{
name: 'Feedback Survey Test',
asset_type: 'survey',
},
);
http.request
request(method, path, [options]) ⇒ Operation
Make a HTTP request to any KoboToolbox endpoint
Param | Type | Default | Description |
---|---|---|---|
method | string | HTTP method to use | |
path | string | Path to resource | |
[options] | HTTPRequestOptions | {} | An object containing query, headers, and body for the request |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the KoboToolbox server (excluding the body) |
references | An array containing all previous data objects |
Example: Bulk updating of submissions |
http.request("PATCH", `assets/${$.form_uid}/data/bulk/`, {
body: {
submission_ids: [$.data.submission_id],
data: {
Transaction_status: "success",
},
},
});
Interfaces
HTTPRequestOptions
Options object
Properties
Name | Type | Default | Description |
---|---|---|---|
query | object | An object of query parameters to be encoded into the URL | |
headers | object | An object of all request headers | |
body | object | The request body (as JSON) | |
maxRedirections | number | The maximum number of redirects to follow | |
[parseAs] | string | "'json'" | The response format to parse (e.g., 'json', 'text', or 'stream') |